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 );
80 std::set<int> highlightedNets = rs->GetHighlightNetCodes();
81 const std::set<int>& hiddenNets = rs->GetHiddenNets();
83 std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
84 std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
85 const std::map<int, wxString>& netclassMap =
m_data->GetNetclassMap();
94 visibleLayers.set( rs->GetPrimaryHighContrastLayer() );
100 visibleLayers.set( layer );
108 if( hiddenNets.count( l.netCode ) )
111 if( colorByNet && netColors.count( l.netCode ) )
112 color = netColors.at( l.netCode );
113 else if( colorByNet && netclassMap.count( l.netCode )
114 && netclassColors.count( netclassMap.at( l.netCode ) ) )
115 color = netclassColors.at( netclassMap.at( l.netCode ) );
117 color = defaultColor;
119 if(
color == COLOR4D::UNSPECIFIED )
120 color = defaultColor;
122 gal->SetStrokeColor(
color.Brightened( 0.5 ) );
126 gal->DrawLine(
VECTOR2I( l.a.x - CROSS_SIZE, l.a.y - CROSS_SIZE ),
127 VECTOR2I( l.b.x + CROSS_SIZE, l.b.y + CROSS_SIZE ) );
128 gal->DrawLine(
VECTOR2I( l.a.x - CROSS_SIZE, l.a.y + CROSS_SIZE ),
129 VECTOR2I( l.b.x + CROSS_SIZE, l.b.y - CROSS_SIZE ) );
135 auto dx = l.b.x - l.a.x;
136 auto dy = l.b.y - l.a.y;
137 const auto center =
VECTOR2I( l.a.x + 0.5 * dx - 0.1 * dy,
138 l.a.y + 0.5 * dy + 0.1 * dx );
139 gal->DrawCurve( l.a, center, center, l.b );
143 gal->DrawLine( l.a, l.b );
148 for(
int i = 1 ; i <
m_data->GetNetCount(); ++i )
150 if( hiddenNets.count( i ) )
158 if( colorByNet && netColors.count( i ) )
159 color = netColors.at( i );
160 else if( colorByNet && netclassMap.count( i )
161 && netclassColors.count( netclassMap.at( i ) ) )
162 color = netclassColors.at( netclassMap.at( i ) );
164 color = defaultColor;
166 if(
color == COLOR4D::UNSPECIFIED )
167 color = defaultColor;
170 if( highlightedNets.count( i ) )
171 gal->SetStrokeColor(
color.Brightened(0.8) );
173 gal->SetStrokeColor(
color );
180 const auto& sourceNode = edge.GetSourceNode();
181 const auto& targetNode = edge.GetTargetNode();
182 const VECTOR2I source( sourceNode->Pos() );
183 const VECTOR2I target( targetNode->Pos() );
185 if( !sourceNode->Valid() || !targetNode->Valid() )
188 bool enable = !sourceNode->GetNoLine() && !targetNode->GetNoLine();
195 if( rs->GetGlobalRatsnestLinesEnabled() )
196 show = sourceNode->Parent()->GetLocalRatsnestVisible() &&
197 targetNode->Parent()->GetLocalRatsnestVisible();
199 show = sourceNode->Parent()->GetLocalRatsnestVisible() ||
200 targetNode->Parent()->GetLocalRatsnestVisible();
202 if( onlyVisibleLayers && show )
204 LSET sourceLayers = sourceNode->Parent()->GetLayerSet();
205 LSET targetLayers = targetNode->Parent()->GetLayerSet();
207 if( !( sourceLayers & visibleLayers ).any() ||
208 !( targetLayers & visibleLayers ).any() )
212 if ( enable && show )
214 if ( source == target )
216 gal->DrawLine(
VECTOR2I( source.x - CROSS_SIZE, source.y - CROSS_SIZE ),
217 VECTOR2I( source.x + CROSS_SIZE, source.y + CROSS_SIZE ) );
218 gal->DrawLine(
VECTOR2I( source.x - CROSS_SIZE, source.y + CROSS_SIZE ),
219 VECTOR2I( source.x + CROSS_SIZE, source.y - CROSS_SIZE ) );
225 auto dx = target.x - source.x;
226 auto dy = target.y - source.y;
227 const auto center =
VECTOR2I( source.x + 0.5 * dx - 0.1 * dy,
228 source.y + 0.5 * dy + 0.1 * dx );
229 gal->DrawCurve( source, center, center, target );
233 gal->DrawLine( source, target );
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
const std::vector< CN_EDGE > GetUnconnected() const
Return pointer to a vector of edges that makes ratsnest for a given net.
Ratsnest lines are drawn to items on visible layers only.
void ViewGetLayers(int aLayers[], int &aCount) const override
Class that computes missing connections on a PCB.
the 3d code uses this value
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
RATSNEST_VIEW_ITEM(std::shared_ptr< CONNECTIVITY_DATA > aData)
Class that draws missing connections on a PCB.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Classes used in Pcbnew, CvPcb and GerbView.
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
std::shared_ptr< CONNECTIVITY_DATA > m_data
Object containing ratsnest data.
const BOX2I ViewBBox() const override
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Board layer functions and definitions.
Net (and netclass) colors are not shown.
A base class for most all the KiCad significant classes used in schematics and boards.
Describe ratsnest for a single net.
Inactive layers are hidden.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
A color representation with 4 components: red, green, blue, alpha.