KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_tuning_pattern.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2023 Alex Shvartzkop <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <bitmaps.h>
24#include <board.h>
25#include <pcb_generator.h>
26#include <pcb_track.h>
28#include <pcb_base_edit_frame.h>
29#include <router/pns_meander.h>
31#include <router/pns_router.h>
33
34
35namespace KIGFX
36{
37 class VIEW;
38 class RENDER_SETTINGS;
39}
40
47
48
50{
51public:
53
54 wxString GetClass() const override;
55
56#if defined(DEBUG)
57 void Show( int nestLevel, std::ostream& os ) const override;
58#endif
59
60 VECTOR2I GetPosition() const override;
61 void SetPosition( const VECTOR2I& aPos ) override;
62
63 void SetMinMax( const double aMin, const double aMax );
64 void SetChainMinMax( const double aMin, const double aMax );
65
66 void ClearMinMax();
67 void ClearChainMinMax();
68
69 void SetCurrent( const double aCurrent, const wxString& aLabel );
70
71 void SetIsTimeDomain( const bool aIsTimeDomain );
72
73 const BOX2I ViewBBox() const override;
74
75 std::vector<int> ViewGetLayers() const override;
76
77 void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
78
79protected:
82 double m_min;
83 double m_max;
84 double m_current;
85 wxString m_currentLabel; // Header line label ("current length" etc.)
86 wxString m_currentText; // (unused now for dual-line layout but kept for compatibility)
87 wxString m_minText;
88 wxString m_maxText;
89 double m_chainMin = 0.0;
90 double m_chainMax = 0.0;
94 wxString m_scopeLine;
95 wxString m_netValue;
96 wxString m_chainValue;
97 bool m_hasSignalValue = false;
98public:
99 void SetScopeLine( const wxString& aLine ) { m_scopeLine = aLine; }
100 void SetNetAndSignalValues( const wxString& aNetVal, const wxString& aSignalVal, bool aHasSignal )
101 {
102 m_netValue = aNetVal;
103 m_chainValue = aSignalVal;
104 m_hasSignalValue = aHasSignal;
105 }
106};
107
108
110{
111public:
112 static const wxString GENERATOR_TYPE;
113 static const wxString DISPLAY_NAME;
114
115 PCB_TUNING_PATTERN( BOARD_ITEM* aParent = nullptr, PCB_LAYER_ID aLayer = F_Cu,
117
118 wxString GetGeneratorType() const override { return GENERATOR_TYPE; }
119
120 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override
121 {
122 return _( "Tuning Pattern" );
123 }
124
125 wxString GetFriendlyName() const override
126 {
127 return _( "Tuning Pattern" );
128 }
129
130 wxString GetPluralName() const override
131 {
132 return _( "Tuning Patterns" );
133 }
134
135 wxString GetCommitMessage() const override
136 {
137 return _( "Edit Tuning Pattern" );
138 }
139
140 BITMAPS GetMenuImage() const override
141 {
142 switch( m_tuningMode )
143 {
144 case SINGLE: return BITMAPS::ps_tune_length; break;
147 }
148
149 return BITMAPS::unknown;
150 }
151
153 BOARD_CONNECTED_ITEM* aStartItem,
154 LENGTH_TUNING_MODE aMode );
155
156 void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit ) override;
157 bool Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit ) override;
158 void EditFinish( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit ) override;
159 void EditCancel( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit ) override;
160
161 void Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit ) override;
162
163 bool MakeEditPoints( EDIT_POINTS& points ) const override;
164
165 bool UpdateFromEditPoints( EDIT_POINTS& aEditPoints ) override;
166
167 bool UpdateEditPoints( EDIT_POINTS& aEditPoints ) override;
168
169 void Move( const VECTOR2I& aMoveVector ) override
170 {
171 m_origin += aMoveVector;
172 m_end += aMoveVector;
173
174 if( !this->HasFlag( IN_EDIT ) )
175 {
176 PCB_GROUP::Move( aMoveVector );
177
178 if( m_baseLine )
179 m_baseLine->Move( aMoveVector );
180
182 m_baseLineCoupled->Move( aMoveVector );
183 }
184 }
185
186 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override
187 {
188 if( !this->HasFlag( IN_EDIT ) )
189 {
190 PCB_GENERATOR::Rotate( aRotCentre, aAngle );
191 RotatePoint( m_end, aRotCentre, aAngle );
192
193 if( m_baseLine )
194 m_baseLine->Rotate( aAngle, aRotCentre );
195
197 m_baseLineCoupled->Rotate( aAngle, aRotCentre );
198 }
199 }
200
201 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override
202 {
203 if( !this->HasFlag( IN_EDIT ) )
204 {
205 PCB_GENERATOR::Flip( aCentre, aFlipDirection );
206
207 baseMirror( aCentre, aFlipDirection );
208 }
209 }
210
211 void Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override
212 {
213 Mirror( MIRROR_AXIS( aCentre, aFlipDirection ) );
214 }
215
216 void Mirror( const SEG& aAxis ) override
217 {
218 if( !this->HasFlag( IN_EDIT ) )
219 {
220 PCB_GENERATOR::Mirror( aAxis );
221
222 baseMirror( aAxis );
223 }
224 }
225
226 void SetLayer( PCB_LAYER_ID aLayer ) override
227 {
228 PCB_GENERATOR::SetLayer( aLayer );
229
230 for( BOARD_ITEM* item : GetBoardItems() )
231 item->SetLayer( aLayer );
232 }
233
234 PCB_LAYER_ID GetLayer() const override
235 {
236 for( BOARD_ITEM* item : GetBoardItems() )
237 {
238 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
239 return track->GetLayer();
240 }
241
243 }
244
245 const BOX2I GetBoundingBox() const override
246 {
247 BOX2I bbox = getOutline().BBox();
248
249 // The outline is synthesized from the baseline and the meander settings, so it can both be
250 // empty and under-cover the copper. PCB_GROUP inflates unconditionally, so skip it when
251 // there are no members rather than absorb a half-millimetre box at the origin.
252 if( !m_items.empty() )
254
255 return bbox;
256 }
257
258 std::vector<int> ViewGetLayers() const override
259 {
260 return { LAYER_ANCHOR, GetLayer() };
261 }
262
263 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
264 {
265 if( getOutline().Collide( aPosition, aAccuracy ) )
266 return true;
267
268 // Members of a generator are never selectable on their own, so the pattern has to answer
269 // for any copper the outline misses
270 for( BOARD_ITEM* item : GetBoardItems() )
271 {
272 if( item->HitTest( aPosition, aAccuracy ) )
273 return true;
274 }
275
276 return false;
277 }
278
279 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const override
280 {
281 bool anyItems = false;
282
283 for( BOARD_ITEM* item : GetBoardItems() )
284 {
285 anyItems = true;
286
287 if( aContained )
288 {
289 if( !item->HitTest( aRect, true, aAccuracy ) )
290 return false;
291 }
292 else if( item->HitTest( aRect, false, aAccuracy ) )
293 {
294 return true;
295 }
296 }
297
298 if( anyItems )
299 return aContained;
300
301 BOX2I sel = aRect;
302
303 if( aAccuracy )
304 sel.Inflate( aAccuracy );
305
306 // Convert selection box to polygon for accurate hit testing against the actual outline
307 SHAPE_LINE_CHAIN selPoly(
308 {
309 sel.GetOrigin(),
310 VECTOR2I( sel.GetRight(), sel.GetTop() ),
311 sel.GetEnd(),
312 VECTOR2I( sel.GetLeft(), sel.GetBottom() )
313 },
314 true );
315
316 return KIGEOM::ShapeHitTest( selPoly, getOutline(), aContained );
317 }
318
319 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override
320 {
321 bool anyItems = false;
322
323 for( BOARD_ITEM* item : GetBoardItems() )
324 {
325 anyItems = true;
326
327 if( aContained )
328 {
329 if( !item->HitTest( aPoly, true ) )
330 return false;
331 }
332 else if( item->HitTest( aPoly, false ) )
333 {
334 return true;
335 }
336 }
337
338 if( anyItems )
339 return aContained;
340
341 return KIGEOM::ShapeHitTest( aPoly, getOutline(), aContained );
342 }
343
344 const BOX2I ViewBBox() const override { return GetBoundingBox(); }
345
346 EDA_ITEM* Clone() const override { return new PCB_TUNING_PATTERN( *this ); }
347
348 void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override final;
349
354 bool IsSelectableAsConnected() const override { return true; }
355
356 const VECTOR2I& GetEnd() const { return m_end; }
357 void SetEnd( const VECTOR2I& aValue ) { m_end = aValue; }
358
359 int GetEndX() const { return m_end.x; }
360 void SetEndX( int aValue ) { m_end.x = aValue; }
361
362 int GetEndY() const { return m_end.y; }
363 void SetEndY( int aValue ) { m_end.y = aValue; }
364
365 int GetWidth() const
366 {
367 for( BOARD_ITEM* item : GetBoardItems() )
368 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
369 return static_cast<PCB_TRACK*>( item )->GetWidth();
370
371 return m_trackWidth;
372 }
373
374 void SetWidth( int aValue )
375 {
376 m_trackWidth = aValue;
377 }
378
379 int GetNetCode() const
380 {
381 for( BOARD_ITEM* item : GetBoardItems() )
382 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
383 return bci->GetNetCode();
384
385 return 0;
386 }
387
388 void SetNetCode( int aNetCode )
389 {
390 if( BOARD* board = GetBoard() )
391 {
392 if( NETINFO_ITEM* net = board->FindNet( aNetCode ) )
393 m_lastNetName = net->GetNetname();
394 else
395 m_lastNetName.clear();
396 }
397
398 for( BOARD_ITEM* item : GetBoardItems() )
399 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
400 bci->SetNetCode( aNetCode );
401 }
402
403 bool HasSolderMask() const
404 {
405 for( BOARD_ITEM* item : GetBoardItems() )
406 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
407 return track->HasSolderMask();
408
409 return true;
410 }
411
412 void SetHasSolderMask( bool aVal )
413 {
414 for( BOARD_ITEM* item : GetBoardItems() )
415 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
416 track->SetHasSolderMask( aVal );
417 }
418
419 std::optional<int> GetLocalSolderMaskMargin() const
420 {
421 for( BOARD_ITEM* item : GetBoardItems() )
422 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
423 return track->GetLocalSolderMaskMargin();
424
425 return std::optional<int>();
426 }
427
428 void SetLocalSolderMaskMargin( std::optional<int> aMargin )
429 {
430 for( BOARD_ITEM* item : GetBoardItems() )
431 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
432 track->SetLocalSolderMaskMargin( aMargin );
433 }
434
437
438 // The un-meandered route the pattern was placed over; the outline is derived from it.
439 const std::optional<SHAPE_LINE_CHAIN>& GetBaseLine() const { return m_baseLine; }
440 void SetBaseLine( const SHAPE_LINE_CHAIN& aBaseLine ) { m_baseLine = aBaseLine; }
441
442 const std::optional<SHAPE_LINE_CHAIN>& GetBaseLineCoupled() const { return m_baseLineCoupled; }
443 void SetBaseLineCoupled( const SHAPE_LINE_CHAIN& aBaseLine ) { m_baseLineCoupled = aBaseLine; }
444
445 int GetDiffPairGap() const { return m_diffPairGap; }
446 void SetDiffPairGap( int aValue ) { m_diffPairGap = aValue; }
447
448 const wxString& GetLastNetName() const { return m_lastNetName; }
449 void SetLastNetName( const wxString& aNetName ) { m_lastNetName = aNetName; }
450
461
464
465 const wxString& GetTuningInfo() const { return m_tuningInfo; }
466
468 bool HasRuleTarget() const { return m_hasRuleTarget; }
469
471 bool HasMeanders() const;
472
477 void ApplyToolSettings( const PNS::MEANDER_SETTINGS& aToolSettings );
478
481
490 const PNS::MEANDER_SETTINGS& aSettings, bool aIncludeTargets );
491
492 int GetMinAmplitude() const { return m_settings.m_minAmplitude; }
493 void SetMinAmplitude( int aValue )
494 {
495 aValue = std::max( aValue, 0 );
496
497 m_settings.m_minAmplitude = aValue;
498
499 if( m_settings.m_maxAmplitude < m_settings.m_minAmplitude )
500 m_settings.m_maxAmplitude = m_settings.m_minAmplitude;
501 }
502
503 int GetMaxAmplitude() const { return m_settings.m_maxAmplitude; }
504 void SetMaxAmplitude( int aValue )
505 {
506 aValue = std::max( aValue, 0 );
507
508 m_settings.m_maxAmplitude = aValue;
509
510 if( m_settings.m_maxAmplitude < m_settings.m_minAmplitude )
511 m_settings.m_minAmplitude = m_settings.m_maxAmplitude;
512 }
513
514 // Update the initial side one time at EditStart based on m_end.
516
517 PNS::MEANDER_SIDE GetInitialSide() const { return m_settings.m_initialSide; }
518 void SetInitialSide( PNS::MEANDER_SIDE aValue ) { m_settings.m_initialSide = aValue; }
519
520 int GetSpacing() const { return m_settings.m_spacing; }
521 void SetSpacing( int aValue ) { m_settings.m_spacing = aValue; }
522
523 std::optional<int> GetTargetLength() const
524 {
525 if( m_settings.m_targetLength.Opt() == PNS::MEANDER_SETTINGS::LENGTH_UNCONSTRAINED )
526 return std::optional<int>();
527 else
528 return m_settings.m_targetLength.Opt();
529 }
530
531 void SetTargetLength( std::optional<int> aValue )
532 {
533 m_settings.m_isTimeDomain = false;
534
535 if( aValue.has_value() )
536 m_settings.SetTargetLength( aValue.value() );
537 else
539 }
540
541 std::optional<int> GetTargetDelay() const
542 {
543 if( m_settings.m_targetLengthDelay.Opt() == PNS::MEANDER_SETTINGS::DELAY_UNCONSTRAINED )
544 return std::optional<int>();
545 else
546 return m_settings.m_targetLengthDelay.Opt();
547 }
548
549 void SetTargetDelay( std::optional<int> aValue )
550 {
551 m_settings.m_isTimeDomain = true;
552
553 if( aValue.has_value() )
554 m_settings.SetTargetLengthDelay( aValue.value() );
555 else
557 }
558
559 int GetTargetSkew() const { return m_settings.m_targetSkew.Opt(); }
560 void SetTargetSkew( int aValue ) { m_settings.SetTargetSkew( aValue ); }
561
562 int GetTargetSkewDelay() const { return m_settings.m_targetSkewDelay.Opt(); }
563 void SetTargetSkewDelay( int aValue ) { m_settings.SetTargetSkewDelay( aValue ); }
564
565 bool GetOverrideCustomRules() const { return m_settings.m_overrideCustomRules; }
566 void SetOverrideCustomRules( bool aOverride ) { m_settings.m_overrideCustomRules = aOverride; }
567
568 int GetCornerRadiusPercentage() const { return m_settings.m_cornerRadiusPercentage; }
569 void SetCornerRadiusPercentage( int aValue ) { m_settings.m_cornerRadiusPercentage = aValue; }
570
571 bool IsSingleSided() const { return m_settings.m_singleSided; }
572 void SetSingleSided( bool aValue ) { m_settings.m_singleSided = aValue; }
573
574 bool IsRounded() const { return m_settings.m_cornerStyle == PNS::MEANDER_STYLE_ROUND; }
575 void SetRounded( bool aFlag ) { m_settings.m_cornerStyle = aFlag ? PNS::MEANDER_STYLE_ROUND
577
578 std::vector<std::pair<wxString, wxVariant>> GetRowData() override
579 {
580 std::vector<std::pair<wxString, wxVariant>> data = PCB_GENERATOR::GetRowData();
581 data.emplace_back( _HKI( "Net" ), m_lastNetName );
582 data.emplace_back( _HKI( "Tuning" ), m_tuningInfo );
583 return data;
584 }
585
586 const STRING_ANY_MAP GetProperties() const override;
587 void SetProperties( const STRING_ANY_MAP& aProps ) override;
588
589 void Serialize( google::protobuf::Any& aContainer ) const override;
590 bool Deserialize( const google::protobuf::Any& aContainer ) override;
591
592 void rebuildTuningInfo();
593
594 // @return the user-facing status string for a tuning result ("too long", "tuned", ...)
596
597 void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) override;
598
599 std::vector<EDA_ITEM*> GetPreviewItems( GENERATOR_TOOL* aTool, PCB_BASE_EDIT_FRAME* aFrame,
600 bool aStatusItemsOnly = false ) override;
601
602 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
603
604protected:
605 void swapData( BOARD_ITEM* aImage ) override
606 {
607 wxASSERT( aImage->Type() == PCB_GENERATOR_T );
608
609 std::swap( *this, *static_cast<PCB_TUNING_PATTERN*>( aImage ) );
610 }
611
612 bool recoverBaseline( PNS::ROUTER* aRouter, int aPNSLayer );
613
614 bool baselineValid();
615
616 bool initBaseLine( PNS::ROUTER* aRouter, int aPNSLayer, BOARD* aBoard, VECTOR2I& aStart,
617 VECTOR2I& aEnd, NETINFO_ITEM* aNet,
618 std::optional<SHAPE_LINE_CHAIN>& aBaseLine );
619
620 bool initBaseLines( PNS::ROUTER* aRouter, int aPNSLayer, BOARD* aBoard );
621
622 bool removeToBaseline( PNS::ROUTER* aRouter, int aPNSLayer, SHAPE_LINE_CHAIN& aBaseLine );
623
624 bool resetToBaseline( GENERATOR_TOOL* aTool, int aPNSLayer, SHAPE_LINE_CHAIN& aBaseLine,
625 bool aPrimary );
626
628
629 void baseMirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
630 {
631 baseMirror( MIRROR_AXIS( aCentre, aFlipDirection ) );
632 }
633
634 void baseMirror( const SEG& aAxis )
635 {
637
638 if( m_baseLine )
639 {
640 m_baseLine->Mirror( aAxis );
641 m_origin = m_baseLine->CPoint( 0 );
642 m_end = m_baseLine->CLastPoint();
643 }
644
646 m_baseLineCoupled->Mirror( aAxis );
647
648 if( m_settings.m_initialSide == PNS::MEANDER_SIDE_RIGHT )
649 m_settings.m_initialSide = PNS::MEANDER_SIDE_LEFT;
650 else
651 m_settings.m_initialSide = PNS::MEANDER_SIDE_RIGHT;
652 }
653
654protected:
656
658
659 std::optional<SHAPE_LINE_CHAIN> m_baseLine;
660 std::optional<SHAPE_LINE_CHAIN> m_baseLineCoupled;
661
665
667
669 wxString m_tuningInfo;
670 long long m_tuningLength;
671
673
675
676 bool m_hasRuleTarget = false;
677
678 // Bridging cache (pad-to-pad gaps across 2-net series components in a chain)
679public:
680 long long GetCachedBridgingLength( BOARD* aBoard, const wxString& aNetChain, double* aDelayIUOut );
681
682private:
688};
BITMAPS
A list of all bitmap identifiers.
@ ps_diff_pair_tune_length
@ ps_diff_pair_tune_phase
SEG MIRROR_AXIS(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition board_item.h:85
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr const Vec GetEnd() const
Definition box2.h:215
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:597
constexpr coord_type GetLeft() const
Definition box2.h:231
constexpr const Vec & GetOrigin() const
Definition box2.h:213
constexpr coord_type GetRight() const
Definition box2.h:220
constexpr coord_type GetTop() const
Definition box2.h:232
constexpr coord_type GetBottom() const
Definition box2.h:225
The base class for create windows for drawing purpose.
std::unordered_set< EDA_ITEM * > m_items
Definition eda_group.h:105
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition eda_item.h:168
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
Handle actions specific to filling copper zones.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
Handle the data for a net.
Definition netinfo.h:50
Common, abstract interface for edit frames.
void baseMirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
PCB_GENERATOR(BOARD_ITEM *aParent, PCB_LAYER_ID aLayer)
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aMirrorDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
VECTOR2I m_origin
virtual std::vector< std::pair< wxString, wxVariant > > GetRowData()
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
std::unordered_set< BOARD_ITEM * > GetBoardItems() const
void SetTargetSkew(int aValue)
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
bool initBaseLines(PNS::ROUTER *aRouter, int aPNSLayer, BOARD *aBoard)
bool HasRuleTarget() const
True when CreateNew() took the targets from a DRC length, chain length or skew rule.
const STRING_ANY_MAP GetProperties() const override
void ApplyToolSettings(const PNS::MEANDER_SETTINGS &aToolSettings)
Adopt the tuning tool's working settings.
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy) const override
Test if aRect intersects this item.
void SetBaseLine(const SHAPE_LINE_CHAIN &aBaseLine)
void SetEnd(const VECTOR2I &aValue)
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
bool HasMeanders() const
True when any member track leaves the baseline between its end caps, or there is no baseline.
void SetMinAmplitude(int aValue)
bool recoverBaseline(PNS::ROUTER *aRouter, int aPNSLayer)
void SetSpacing(int aValue)
void SetTuningMode(LENGTH_TUNING_MODE aMode)
wxString GetGeneratorType() const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsSelectableAsConnected() const override
Indicates that the tuning pattern can be selected as a connected entity: when the selection crosses o...
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
bool HitTest(const SHAPE_LINE_CHAIN &aPoly, bool aContained) const override
Test if aPoly intersects this item.
static const wxString DISPLAY_NAME
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
PNS::ROUTER_MODE GetPNSMode()
bool initBaseLine(PNS::ROUTER *aRouter, int aPNSLayer, BOARD *aBoard, VECTOR2I &aStart, VECTOR2I &aEnd, NETINFO_ITEM *aNet, std::optional< SHAPE_LINE_CHAIN > &aBaseLine)
void SetTargetSkewDelay(int aValue)
static wxString StatusMessage(PNS::MEANDER_PLACER_BASE::TUNING_STATUS aStatus)
PCB_TUNING_PATTERN(BOARD_ITEM *aParent=nullptr, PCB_LAYER_ID aLayer=F_Cu, LENGTH_TUNING_MODE aMode=LENGTH_TUNING_MODE::SINGLE)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void swapData(BOARD_ITEM *aImage) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetWidth(int aValue)
PNS::MEANDER_SIDE GetInitialSide() const
std::optional< int > GetLocalSolderMaskMargin() const
const VECTOR2I & GetEnd() const
void SetInitialSide(PNS::MEANDER_SIDE aValue)
wxString GetFriendlyName() const override
void Mirror(const SEG &aAxis) override
Mirror this object about an arbitrary axis, without changing its layer or side.
void SetTargetDelay(std::optional< int > aValue)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
static PNS::MEANDER_SETTINGS & DefaultSettings(BOARD_DESIGN_SETTINGS &aBds, LENGTH_TUNING_MODE aMode)
The per-mode tool defaults stored on the board.
wxString GetCommitMessage() const override
static void StoreDefaults(BOARD_DESIGN_SETTINGS &aBds, LENGTH_TUNING_MODE aMode, const PNS::MEANDER_SETTINGS &aSettings, bool aIncludeTargets)
Remember the tool's settings as the per-mode default for the next activation.
LENGTH_TUNING_MODE GetTuningMode() const
const PNS::MEANDER_SETTINGS & GetSettings() const
void SetHasSolderMask(bool aVal)
std::optional< int > GetTargetDelay() const
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::vector< EDA_ITEM * > GetPreviewItems(GENERATOR_TOOL *aTool, PCB_BASE_EDIT_FRAME *aFrame, bool aStatusItemsOnly=false) override
void SetLastNetName(const wxString &aNetName)
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void EditStart(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
void baseMirror(const SEG &aAxis)
void baseMirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
long long GetCachedBridgingLength(BOARD *aBoard, const wxString &aNetChain, double *aDelayIUOut)
void SetOverrideCustomRules(bool aOverride)
void SetRounded(bool aFlag)
const wxString & GetLastNetName() const
LENGTH_TUNING_MODE m_tuningMode
std::vector< std::pair< wxString, wxVariant > > GetRowData() override
const std::optional< SHAPE_LINE_CHAIN > & GetBaseLine() const
static const wxString GENERATOR_TYPE
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool resetToBaseline(GENERATOR_TOOL *aTool, int aPNSLayer, SHAPE_LINE_CHAIN &aBaseLine, bool aPrimary)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
bool MakeEditPoints(EDIT_POINTS &points) const override
void SetCornerRadiusPercentage(int aValue)
PNS::MEANDER_PLACER_BASE::TUNING_STATUS m_tuningStatus
std::optional< SHAPE_LINE_CHAIN > m_baseLineCoupled
const BOARD * m_cachedBridgingBoardPtr
void SetProperties(const STRING_ANY_MAP &aProps) override
wxString GetPluralName() const override
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override final
Draw the parts of the object belonging to layer aLayer.
void Remove(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
const wxString & GetTuningInfo() const
bool UpdateFromEditPoints(EDIT_POINTS &aEditPoints) override
std::optional< SHAPE_LINE_CHAIN > m_baseLine
PNS::MEANDER_SETTINGS m_settings
void SetEndX(int aValue)
void SetDiffPairGap(int aValue)
void ShowPropertiesDialog(PCB_BASE_EDIT_FRAME *aEditFrame) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
bool Update(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
void SetNetCode(int aNetCode)
bool UpdateEditPoints(EDIT_POINTS &aEditPoints) override
void EditCancel(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
bool GetOverrideCustomRules() const
void SetMaxAmplitude(int aValue)
PNS::MEANDER_SETTINGS & GetSettings()
const std::optional< SHAPE_LINE_CHAIN > & GetBaseLineCoupled() const
void SetSingleSided(bool aValue)
bool removeToBaseline(PNS::ROUTER *aRouter, int aPNSLayer, SHAPE_LINE_CHAIN &aBaseLine)
std::optional< int > GetTargetLength() const
void EditFinish(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetCornerRadiusPercentage() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SHAPE_LINE_CHAIN getOutline() const
void SetEndY(int aValue)
void SetTargetLength(std::optional< int > aValue)
static PCB_TUNING_PATTERN * CreateNew(GENERATOR_TOOL *aTool, PCB_BASE_EDIT_FRAME *aFrame, BOARD_CONNECTED_ITEM *aStartItem, LENGTH_TUNING_MODE aMode)
void SetBaseLineCoupled(const SHAPE_LINE_CHAIN &aBaseLine)
TUNING_STATUS
Result of the length tuning operation.
Dimensions for the meandering algorithm.
Definition pns_meander.h:70
static const long long int LENGTH_UNCONSTRAINED
Definition pns_meander.h:73
static const long long int DELAY_UNCONSTRAINED
Definition pns_meander.h:76
Definition seg.h:38
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
A name/value tuple with unique names and wxAny values.
void SetIsTimeDomain(const bool aIsTimeDomain)
void SetCurrent(const double aCurrent, const wxString &aLabel)
wxString GetClass() const override
Return the class name.
VECTOR2I GetPosition() const override
void SetScopeLine(const wxString &aLine)
void SetMinMax(const double aMin, const double aMax)
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
void SetChainMinMax(const double aMin, const double aMax)
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
TUNING_STATUS_VIEW_ITEM(PCB_BASE_EDIT_FRAME *aFrame)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void SetNetAndSignalValues(const wxString &aNetVal, const wxString &aSignalVal, bool aHasSignal)
void SetPosition(const VECTOR2I &aPos) override
#define _(s)
#define IN_EDIT
Item currently edited.
a few functions useful in geometry calculations.
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:244
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_Cu
Definition layer_ids.h:60
FLIP_DIRECTION
Definition mirror.h:26
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
MEANDER_SIDE
Initial side the meander is placed on.
Definition pns_meander.h:60
@ MEANDER_SIDE_RIGHT
Definition pns_meander.h:63
@ MEANDER_SIDE_LEFT
Definition pns_meander.h:61
@ MEANDER_STYLE_ROUND
Definition pns_meander.h:54
@ MEANDER_STYLE_CHAMFER
Definition pns_meander.h:55
ROUTER_MODE
Definition pns_router.h:68
@ PNS_MODE_TUNE_DIFF_PAIR
Definition pns_router.h:72
@ PNS_MODE_TUNE_SINGLE
Definition pns_router.h:71
@ PNS_MODE_TUNE_DIFF_PAIR_SKEW
Definition pns_router.h:73
#define _HKI(x)
Definition page_info.cpp:40
LENGTH_TUNING_MODE
@ DIFF_PAIR
@ DIFF_PAIR_SKEW
static bool Collide(const SHAPE_CIRCLE &aA, const SHAPE_CIRCLE &aB, int aClearance, int *aActual, VECTOR2I *aLocation, VECTOR2I *aMTV)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:227
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708