30#include <magic_enum.hpp>
91 return wxT(
"TUNING_STATUS" );
95void TUNING_STATUS_VIEW_ITEM::Show(
int nestLevel, std::ostream& os )
const {}
118 m_max = std::numeric_limits<double>::max();
163 gal->
Scale( { 1., 1. } );
174 VECTOR2I offset( margin.
x * 2, -( size.
y + margin.
y * 2 ) );
176 if( drawingDropShadows )
181 gal->
SetStrokeColor( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
182 KIGFX::COLOR4D bgColor( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
191 COLOR4D bg = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
192 COLOR4D normal = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT );
196 double bg_h, bg_s, bg_l;
197 bg.
ToHSL( bg_h, bg_s, bg_l );
200 red.FromHSL( 0.0, 1.0, bg_l < 0.5 ? 0.7 : 0.3 );
201 green.FromHSL( 120.0, 1.0, bg_l < 0.5 ? 0.8 : 0.2 );
226 textPos.
x += glyphWidth * 11 + margin.
x;
227 font->
Draw( gal,
_(
"min" ), textPos, textAttrs, fontMetrics );
229 textPos.
x += glyphWidth * 7 + margin.
x;
230 font->
Draw( gal,
_(
"max" ), textPos, textAttrs, fontMetrics );
240 textPos.
x += glyphWidth * 11 + margin.
x;
242 font->
Draw( gal,
m_minText, textPos, textAttrs, fontMetrics );
244 textPos.
x += glyphWidth * 7 + margin.
x;
246 font->
Draw( gal,
m_maxText, textPos, textAttrs, fontMetrics );
254 if( aStr ==
"single" )
256 else if( aStr ==
"diff_pair" )
258 else if( aStr ==
"diff_pair_skew" )
262 wxFAIL_MSG( wxS(
"Unknown length tuning token" ) );
275 default: wxFAIL;
return "";
282 switch( aRouterMode )
294 if( aStr ==
"default" )
296 else if( aStr ==
"left" )
298 else if( aStr ==
"right" )
302 wxFAIL_MSG( wxS(
"Unknown length-tuning side token" ) );
315 default: wxFAIL;
return "";
322 if( aStr ==
"too_long" )
324 else if( aStr ==
"too_short" )
326 else if( aStr ==
"tuned" )
330 wxFAIL_MSG( wxS(
"Unknown tuning status token" ) );
343 default: wxFAIL;
return "";
373 if( aNet && track->GetNet() != aNet )
388 SEG seg( track->GetStart(), track->GetEnd() );
392 SEG::ecoord dist_sq = ( nearest - aP ).SquaredEuclideanNorm();
394 if( dist_sq < minDist_sq )
396 minDist_sq = dist_sq;
400 *aNearestTrack = track;
445 if( !constraint.
IsNull() )
465 if( !constraint.
IsNull() )
493 aCommit->
Add(
this );
519 centerlineOffsetEnd =
526 baseEnd.
A += centerlineOffsetEnd;
527 baseEnd.
B += centerlineOffsetEnd;
529 if( baseEnd.
A != baseEnd.
B )
559 &pnsItem,
nullptr, layer, &constraint ) )
585 pnsCoupledItem.
SetParent( coupledTrack );
586 pnsCoupledItem.
SetNet( coupledNet );
591 &pnsItem, &pnsCoupledItem, layer, &constraint ) )
611 &pnsItem, &pnsCoupledItem, layer, &constraint ) )
639 static const int candidateCount = 2;
645 for(
int i = 0; i < candidateCount; i++ )
647 prioritized[i] =
nullptr;
652 for(
int slopRadius : { 0, maxSlopRadius } )
661 if( !item->IsRoutable() )
664 if( !item->Layers().Overlaps( aLayer ) )
674 SEG::ecoord d0 = ( nearest - aWhere ).SquaredEuclideanNorm();
679 if( aBaseline.PointCount() > 0 )
684 if( aBaseline.SegmentCount() > 0 )
687 dcBaseline = ( aBaseline.CPoint( 0 ) - target ).SquaredEuclideanNorm();
689 if( dcBaseline > distBaseline[1] )
692 distBaseline[1] = dcBaseline;
695 prioritized[1] = linked;
704 SEG::ecoord dd = ( aWhere - nearest ).SquaredEuclideanNorm();
709 if( aBaseline.PointCount() > 0 )
714 if( aBaseline.SegmentCount() > 0 )
717 dcBaseline = ( aBaseline.CPoint( 0 ) - target ).SquaredEuclideanNorm();
719 if( dcBaseline > distBaseline[1] )
722 distBaseline[1] = dcBaseline;
725 prioritized[1] = segm;
734 for(
int i = 0; i < candidateCount; i++ )
738 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
741 aPointOut = point[i];
777 std::optional<SHAPE_LINE_CHAIN>& aBaseLine )
784 VECTOR2I startSnapPoint, endSnapPoint;
789 wxASSERT( startItem );
792 if( !startItem || !endItem )
800 wxASSERT(
chain.PointOnEdge( startSnapPoint, 40000 ) );
801 wxASSERT(
chain.PointOnEdge( endSnapPoint, 40000 ) );
807 chain.Split( startSnapPoint, endSnapPoint, pre, mid, post );
822 wxCHECK( track,
false );
838 return initBaseLine( aRouter, aPNSLayer, aBoard, coupledStart, coupledEnd, coupledNet,
873 VECTOR2I startSnapPoint, endSnapPoint;
876 aPNSLayer, startSnapPoint, endSnapPoint );
878 wxCHECK( pnsLine,
false );
883 pnsLine->CLine().
Split( startSnapPoint, endSnapPoint, pre, mid, post );
891 straightChain.
Append( pre );
892 straightChain.
Append( aBaseLine );
893 straightChain.
Append( post );
896 PNS::LINE straightLine( *pnsLine, straightChain );
937 const std::vector<GENERATOR_PNS_CHANGES>& allPnsChanges = aTool->
GetRouterChanges();
941 const std::set<BOARD_ITEM*> routerRemovedItems = pnsChanges.removedItems;
942 const std::set<BOARD_ITEM*> routerAddedItems = pnsChanges.addedItems;
950 item->ClearSelected();
955 aCommit->
Add( item );
988 if( lineWidth == 0 || li->Width() < lineWidth )
989 lineWidth = li->Width();
1010 recoverLine.
SetNet( recoverNet );
1011 branch->
Add( recoverLine,
false );
1019 recoverLineCoupled.
SetWidth( lineWidth );
1021 recoverLineCoupled.
SetNet( recoverCoupledNet );
1022 branch->
Add( recoverLineCoupled,
false );
1040 VECTOR2I startSnapPoint, endSnapPoint;
1043 aPNSLayer, startSnapPoint, endSnapPoint );
1057 pnsLine->CLine().
Split( startSnapPoint, endSnapPoint, pre, mid, post );
1059 straightChain.
Append( pre );
1060 straightChain.
Append( aBaseLine );
1061 straightChain.
Append( post );
1065 branch->
Remove( *pnsLine );
1078 m_end = endSnapPoint;
1085 newLineChain.
Append( pre );
1086 newLineChain.
Append( mid );
1087 newLineChain.
Append( post );
1099 straightChain.
Split( start,
end, pre, mid, post );
1101 newLineChain.
Append( pre );
1102 newLineChain.
Append( mid );
1103 newLineChain.
Append( post );
1109 PNS::LINE newLine( *pnsLine, newLineChain );
1111 branch->
Add( newLine,
false );
1134 auto hideRemovedItems = [&](
bool aHide )
1140 for(
BOARD_ITEM* item : pnsCommit.removedItems )
1143 view->
Hide( item, aHide, aHide );
1186 hideRemovedItems(
true );
1188 VECTOR2I startSnapPoint, endSnapPoint;
1195 wxASSERT( startItem );
1196 wxASSERT( endItem );
1198 if( !startItem || !endItem )
1203 if( !router->
StartRouting( startSnapPoint, startItem, pnslayer ) )
1232 wxString statusMessage;
1239 default: statusMessage =
_(
"unknown" );
break;
1282 bool forceFinish =
true;
1283 bool forceCommit =
false;
1285 router->
FixRoute(
m_end,
nullptr, forceFinish, forceCommit );
1289 const std::vector<GENERATOR_PNS_CHANGES>& pnsCommits = aTool->
GetRouterChanges();
1293 const std::set<BOARD_ITEM*> routerRemovedItems = pnsCommit.removedItems;
1294 const std::set<BOARD_ITEM*> routerAddedItems = pnsCommit.addedItems;
1303 view->
Hide( item,
false );
1310 aCommit->
Add( item );
1340 for(
BOARD_ITEM* item : pnsCommit.removedItems )
1341 view->Hide( item,
false );
1366 base.
A += centerlineOffset;
1367 base.
B += centerlineOffset;
1377 VECTOR2I widthHandleOffset = ( base.
B - base.
A ).Perpendicular().Resize( amplitude );
1379 aPoints.
AddPoint( base.
A + widthHandleOffset );
1385 aPoints.
AddPoint( base.
A + spacingHandleOffset );
1406 base.
A += centerlineOffset;
1407 base.
B += centerlineOffset;
1425 int side = base.
Side( wHandle );
1461 base.
A += centerlineOffset;
1462 base.
B += centerlineOffset;
1472 VECTOR2I widthHandleOffset = ( base.
B - base.
A ).Perpendicular().Resize( amplitude );
1492 int clampedMaxAmplitude =
m_settings.m_maxAmplitude;
1493 int minAllowedAmplitude = 0;
1503 minAllowedAmplitude = baselineOffset +
correction;
1506 clampedMaxAmplitude = std::max( clampedMaxAmplitude, minAllowedAmplitude );
1524 chain.SetClosed(
true );
1629 size = std::max( size,
pcbIUScale.mmToIU( 0.05 ) );
1635 for(
int i = 0; i <
m_baseLine->SegmentCount(); i++ )
1658 for(
int i = 0; i <
chain.SegmentCount(); i++ )
1676 props.
set(
"corner_radius_percent",
m_settings.m_cornerRadiusPercentage );
1697 props.
set(
"override_custom_rules",
m_settings.m_overrideCustomRules );
1713 wxString tuningMode;
1714 aProps.
get_to(
"tuning_mode", tuningMode );
1718 aProps.
get_to(
"initial_side", side );
1722 aProps.
get_to(
"last_status", status );
1728 aProps.
get_to(
"corner_radius_percent",
m_settings.m_cornerRadiusPercentage );
1732 bool rounded =
false;
1733 aProps.
get_to(
"rounded", rounded );
1738 aProps.
get_to_iu(
"target_length", val );
1741 if( aProps.
get_to_iu(
"target_length_min", val ) )
1744 if( aProps.
get_to_iu(
"target_length_max", val ) )
1747 aProps.
get_to_iu(
"target_delay", val );
1750 if( aProps.
get_to_iu(
"target_delay_min", val ) )
1751 m_settings.m_targetLengthDelay.SetMin( val );
1753 if( aProps.
get_to_iu(
"target_delay_max", val ) )
1754 m_settings.m_targetLengthDelay.SetMax( val );
1758 aProps.
get_to_iu(
"target_skew", int_val );
1761 if( aProps.
get_to_iu(
"target_skew_min", int_val ) )
1764 if( aProps.
get_to_iu(
"target_skew_max", int_val ) )
1773 aProps.
get_to(
"override_custom_rules",
m_settings.m_overrideCustomRules );
1786 wxString statusMessage;
1793 default: statusMessage =
_(
"unknown" );
break;
1800 m_tuningInfo.Printf( wxS(
"%s (%s)" ), lengthStr, statusMessage );
1870 commit.
Push(
_(
"Edit Tuning Pattern" ) );
1877 bool aStatusItemsOnly )
1879 std::vector<EDA_ITEM*> previewItems;
1884 if( !aStatusItemsOnly )
1914 static_cast<double>(
m_settings.m_targetLengthDelay.Max() ) );
1926 static_cast<double>(
m_settings.m_targetLength.Max() ) );
1936 statusItem->
SetCurrent(
static_cast<double>( placer->TuningDelayResult() ),
_(
"current skew" ) );
1938 statusItem->
SetCurrent(
static_cast<double>( placer->TuningLengthResult() ),
_(
"current skew" ) );
1943 statusItem->
SetCurrent(
static_cast<double>( placer->TuningDelayResult() ),
_(
"current delay" ) );
1945 statusItem->
SetCurrent(
static_cast<double>( placer->TuningLengthResult() ),
_(
"current length" ) );
1949 previewItems.push_back( statusItem );
1952 return previewItems;
1957 std::vector<MSG_PANEL_ITEM>& aList )
1966 bool mixedWidth =
false;
1978 primaryItem = track;
1979 primaryNet = track->GetNet();
1981 else if( !coupledNet && track->GetNet() != primaryNet )
1983 coupledItem = track;
1984 coupledNet = track->GetNet();
1988 netclass = track->GetEffectiveNetClass();
1991 width = track->GetWidth();
1992 else if( width != track->GetWidth() )
2003 else if( primaryNet )
2009 aList.emplace_back(
_(
"Resolved Netclass" ),
2014 if( width && !mixedWidth )
2022 if( board && primaryItem && primaryItem->
GetNetCode() > 0 )
2025 double trackLen = 0.0;
2026 double lenPadToDie = 0.0;
2027 double trackDelay = 0.0;
2028 double delayPadToDie = 0.0;
2030 std::tie( count, trackLen, lenPadToDie, trackDelay, delayPadToDie ) = board->
GetTrackLength( *primaryItem );
2032 if( coupledItem && coupledItem->
GetNetCode() > 0 )
2034 double coupledLen = 0.0;
2035 double coupledLenPadToDie = 0.0;
2036 double coupledTrackDelay = 0.0;
2037 double doubledDelayPadToDie = 0.0;
2039 std::tie( count, coupledLen, coupledLenPadToDie, coupledTrackDelay, doubledDelayPadToDie ) =
2042 if( trackDelay == 0.0 || coupledTrackDelay == 0.0 )
2050 _(
"Routed Delays" ),
2057 if( trackDelay == 0.0 )
2063 aList.emplace_back(
_(
"Routed Delay" ),
2068 if( lenPadToDie != 0 && delayPadToDie == 0.0 )
2071 aList.emplace_back(
_(
"Pad To Die Length" ), msg );
2074 aList.emplace_back(
_(
"Full Length" ), msg );
2076 else if( delayPadToDie > 0.0 )
2079 aList.emplace_back(
_(
"Pad To Die Delay" ), msg );
2082 aList.emplace_back(
_(
"Full Delay" ), msg );
2094 aList.emplace_back( wxString::Format(
_(
"Target Skew: %s" ), msg ),
2095 wxString::Format(
_(
"(from tuning pattern properties)" ) ) );
2101 if( !msg.IsEmpty() )
2103 aList.emplace_back( wxString::Format(
_(
"Skew Constraints: %s" ), msg ),
2104 wxString::Format(
_(
"(from %s)" ), constraint.
GetName() ) );
2118 caption =
_(
"Target Delay: %s" );
2124 caption =
_(
"Target Length: %s" );
2128 aList.emplace_back( wxString::Format( caption, msg ),
2129 wxString::Format(
_(
"(from tuning pattern properties)" ) ) );
2135 wxString caption =
m_settings.m_isTimeDomain ?
_(
"Delay Constraints: %s" ) :
_(
"Length Constraints: %s" );
2137 if( !msg.IsEmpty() )
2139 aList.emplace_back( wxString::Format( caption, msg ),
2140 wxString::Format(
_(
"(from %s)" ), constraint.
GetName() ) );
2154#define HITTEST_THRESHOLD_PIXELS 5
2174 std::shared_ptr<DRC_ENGINE>& drcEngine = bds.
m_DRCEngine;
2200 auto applyCommonSettings =
2203 const auto& origTargetLength = aPattern->GetSettings().m_targetLength;
2204 const auto& origTargetSkew = aPattern->GetSettings().m_targetSkew;
2206 aPattern->GetSettings() = meanderSettings;
2212 aPattern->GetSettings().m_targetSkew = origTargetSkew;
2215 auto updateHoverStatus =
2218 std::unique_ptr<PCB_TUNING_PATTERN> dummyPattern;
2224 dummyPattern->SetPosition(
m_pickerItem->GetFocusPosition() );
2225 dummyPattern->SetEnd(
m_pickerItem->GetFocusPosition() );
2230 applyCommonSettings( dummyPattern.get() );
2232 dummyPattern->EditStart( generatorTool,
m_board,
nullptr );
2233 dummyPattern->Update( generatorTool,
m_board,
nullptr );
2237 for(
EDA_ITEM* item : dummyPattern->GetPreviewItems( generatorTool,
m_frame ) )
2252 auto updateTuningPattern =
2273 if( evt->IsCancelInteractive() || evt->IsActivate()
2289 else if( evt->IsMotion() )
2299 guide.SetIncludeSecondary(
false );
2301 guide.SetIncludeSecondary(
true );
2303 guide.SetPreferredLayer(
m_frame->GetActiveLayer() );
2314 double min_dist_sq = std::numeric_limits<double>::max();
2316 for(
EDA_ITEM* candidate : collector )
2322 candidatePos =
static_cast<PCB_TRACK*
>( candidate )->GetCenter();
2324 else if( candidate->Type() ==
PCB_ARC_T )
2326 candidatePos =
static_cast<PCB_ARC*
>( candidate )->GetMid();
2329 double dist_sq = ( cursorPos - candidatePos ).SquaredEuclideanNorm();
2331 if( dist_sq < min_dist_sq )
2333 min_dist_sq = dist_sq;
2339 updateHoverStatus();
2348 updateTuningPattern();
2351 else if( evt->IsClick(
BUT_LEFT ) )
2359 m_frame->ShowInfoBarWarning(
_(
"Unable to tune segments inside other "
2360 "tuning patterns." ) );
2373 int dummyClearance = std::numeric_limits<int>::max() / 2;
2378 if(
m_pickerItem->GetEffectiveShape()->Collide( cursorPos, dummyClearance,
2379 &dummyDist, &closestPt ) )
2397 commit.
Push(
_(
"Tune" ) );
2417 meanderSettings.
m_spacing = placer->MeanderSettings().m_spacing;
2419 updateTuningPattern();
2423 m_frame->ShowInfoBarWarning(
_(
"Select a track to tune first." ) );
2434 m_tuningPattern->SetMaxAmplitude( placer->MeanderSettings().m_maxAmplitude );
2435 meanderSettings.
m_maxAmplitude = placer->MeanderSettings().m_maxAmplitude;
2437 updateTuningPattern();
2441 m_frame->ShowInfoBarWarning(
_(
"Select a track to tune first." ) );
2467 updateTuningPattern();
2478 evt->SetPassEvent();
2487 controls->ForceCursorPosition(
false );
2494 m_frame->GetCanvas()->Refresh();
2527 if( layerEnum.
Choices().GetCount() == 0 )
2537 layer->SetChoices( layerEnum.
Choices() );
2547 const wxString groupTechLayers =
_HKI(
"Technical Layers" );
2559 const wxString groupTab =
_HKI(
"Pattern Properties" );
2610 auto isTimeDomain = [](
INSPECTABLE* aItem ) ->
bool
2613 return pattern->GetSettings().m_isTimeDomain;
2618 auto isLengthIsSpaceDomain = [&](
INSPECTABLE* aItem ) ->
bool
2620 return !isSkew( aItem ) && !isTimeDomain( aItem );
2623 auto isLengthIsTimeDomain = [&](
INSPECTABLE* aItem ) ->
bool
2625 return !isSkew( aItem ) && isTimeDomain( aItem );
2628 auto isSkewIsSpaceDomain = [&](
INSPECTABLE* aItem ) ->
bool
2630 return isSkew( aItem ) && !isTimeDomain( aItem );
2633 auto isSkewIsTimeDomain = [&](
INSPECTABLE* aItem ) ->
bool
2635 return isSkew( aItem ) && isTimeDomain( aItem );
2683template <typename
T>
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION selectionClear
Clear the current selection.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
int GetDRCEpsilon() const
Return an epsilon which accounts for rounding errors, etc.
PNS::MEANDER_SETTINGS m_DiffPairMeanderSettings
PNS::MEANDER_SETTINGS m_SingleTrackMeanderSettings
PNS::MEANDER_SETTINGS m_SkewMeanderSettings
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual wxString LayerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
Information pertinent to a Pcbnew printed circuit board.
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
std::tuple< int, double, double, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
const TRACKS & Tracks() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr void SetMaximum()
int GetCount() const
Return the number of objects in the list.
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
const MINOPTMAX< int > & GetValue() const
bool GetOption(OPTIONS option) const
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
The base class for create windows for drawing purpose.
std::unordered_set< EDA_ITEM * > m_items
std::unordered_set< EDA_ITEM * > & GetItems()
void AddItem(EDA_ITEM *aItem)
Add item to group.
A base class for most all the KiCad significant classes used in schematics and boards.
void SetFlags(EDA_ITEM_FLAGS aMask)
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
EDA_ITEM_FLAGS GetFlags() const
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
void AddPoint(const EDIT_POINT &aPoint)
Add an EDIT_POINT.
EDIT_POINT & Point(unsigned int aIndex)
void SetGridConstraint(GRID_CONSTRAINT_TYPE aConstraint)
static const int POINT_SIZE
Single point size in pixels.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
A general implementation of a COLLECTORS_GUIDE.
Used when the right click button is pressed, or when the select tool is in effect.
void Collect(BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
A factory which returns an instance of a PCB_GENERATOR.
void Register(const wxString &aTypeStr, const wxString &aName, std::function< PCB_GENERATOR *(void)> aCreateFunc)
Associate a type string to display name and create function.
static GENERATORS_MGR & Instance()
Class that other classes need to inherit from, in order to be inspectable.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) const
Draw a string.
static const METRICS & Default()
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
void ToHSL(double &aOutHue, double &aOutSaturation, double &aOutLightness) const
Converts current color (stored in RGB) to HSL format.
Abstract interface for drawing on a 2D-surface.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void Restore()
Restore the context.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void Save()
Save the context.
A KIGFX::PREVIEW::DRAW_CONTEXT is a wrapper around a GAL and some other settings that makes it easy t...
void DrawLineDashed(const VECTOR2I &aStart, const VECTOR2I &aEn, int aDashStep, int aDashFill, bool aDeEmphasised)
Draw a dashed line on the current layer.
An interface for classes handling user events controlling the view behavior such as zooming,...
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.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
static const LSET & AllLayersMask()
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
A collection of nets and the parameters used to route or test these nets.
const wxString GetHumanReadableName() const
Gets the consolidated name of this netclass (which may be an aggregate).
Handle the data for a net.
const wxString & GetNetname() const
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION spacingDecrease
static TOOL_ACTION amplIncrease
static TOOL_ACTION amplDecrease
static TOOL_ACTION lengthTunerSettings
static TOOL_ACTION spacingIncrease
const VECTOR2I & GetMid() const
Common, abstract interface for edit frames.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
virtual void SetProperties(const STRING_ANY_MAP &aProps)
PCB_GENERATOR(BOARD_ITEM *aParent, PCB_LAYER_ID aLayer)
virtual const STRING_ANY_MAP GetProperties() const
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
virtual int GetWidth() const
void SetTargetSkew(int aValue)
bool initBaseLines(PNS::ROUTER *aRouter, int aPNSLayer, BOARD *aBoard)
const STRING_ANY_MAP GetProperties() const override
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
void SetMinAmplitude(int aValue)
void SetSpacing(int aValue)
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)
PCB_TUNING_PATTERN(BOARD_ITEM *aParent=nullptr, PCB_LAYER_ID aLayer=F_Cu, LENGTH_TUNING_MODE aMode=LENGTH_TUNING_MODE::SINGLE)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
bool recoverBaseline(PNS::ROUTER *aRouter)
void SetWidth(int aValue)
PNS::MEANDER_SIDE GetInitialSide() const
std::optional< int > GetLocalSolderMaskMargin() const
bool HasSolderMask() const
void SetInitialSide(PNS::MEANDER_SIDE aValue)
wxString GetFriendlyName() const override
void SetTargetDelay(std::optional< int > aValue)
LENGTH_TUNING_MODE GetTuningMode() const
void SetHasSolderMask(bool aVal)
std::optional< int > GetTargetDelay() const
std::vector< EDA_ITEM * > GetPreviewItems(GENERATOR_TOOL *aTool, PCB_BASE_EDIT_FRAME *aFrame, bool aStatusItemsOnly=false) override
int GetMinAmplitude() const
void EditStart(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
void SetOverrideCustomRules(bool aOverride)
void SetRounded(bool aFlag)
LENGTH_TUNING_MODE m_tuningMode
static const wxString GENERATOR_TYPE
bool resetToBaseline(GENERATOR_TOOL *aTool, int aPNSLayer, SHAPE_LINE_CHAIN &aBaseLine, bool aPrimary)
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
void SetProperties(const STRING_ANY_MAP &aProps) 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
bool UpdateFromEditPoints(EDIT_POINTS &aEditPoints) override
std::optional< SHAPE_LINE_CHAIN > m_baseLine
int GetMaxAmplitude() const
PNS::MEANDER_SETTINGS m_settings
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
int GetTargetSkewDelay() const
void EditCancel(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit) override
bool GetOverrideCustomRules() const
void SetMaxAmplitude(int aValue)
PNS::MEANDER_SETTINGS & GetSettings()
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
int GetCornerRadiusPercentage() const
SHAPE_LINE_CHAIN getOutline() const
void SetTargetLength(std::optional< int > aValue)
bool IsSingleSided() const
static PCB_TUNING_PATTERN * CreateNew(GENERATOR_TOOL *aTool, PCB_BASE_EDIT_FRAME *aFrame, BOARD_CONNECTED_ITEM *aStartItem, LENGTH_TUNING_MODE aMode)
int GetTargetSkew() const
Differential Pair length-matching/meandering tool.
std::vector< ITEM * > & Items()
Base class for PNS router board items.
virtual NET_HANDLE Net() const
void SetNet(NET_HANDLE aNet)
void SetLayer(int aLayer)
void SetParent(BOARD_ITEM *aParent)
bool OfKind(int aKindMask) const
virtual VECTOR2I Anchor(int n) const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
const SHAPE_LINE_CHAIN & CLine() const
SHAPE_LINE_CHAIN & Line()
void SetWidth(int aWidth)
Return line width.
virtual int Width() const
bool ContainsLink(const LINKED_ITEM *aItem) const
std::vector< LINKED_ITEM * > & Links()
Base class for Single trace & Differential pair meandering tools, as both of them share a lot of code...
virtual void UpdateSettings(const MEANDER_SETTINGS &aSettings)
TUNING_STATUS
< Result of the length tuning operation
virtual void SpacingStep(int aSign)
Increase/decrease the current meandering spacing by one step.
virtual TUNING_STATUS TuningStatus() const =0
Return the tuning status (too short, too long, etc.) of the trace(s) being tuned.
virtual const MEANDER_SETTINGS & MeanderSettings() const
Return the current meandering configuration.
virtual void AmplitudeStep(int aSign)
Increase/decreases the current meandering amplitude by one step.
virtual long long int TuningLengthResult() const =0
Return the resultant length or skew of the tuned traces.
Dimensions for the meandering algorithm.
void SetTargetLength(long long int aOpt)
bool m_isTimeDomain
The net class this meander pattern belongs to.
static const long long int LENGTH_UNCONSTRAINED
void SetTargetLengthDelay(long long int aOpt)
MINOPTMAX< long long int > m_targetLength
Desired propagation delay of the tuned line.
void SetTargetSkew(int aOpt)
MINOPTMAX< int > m_targetSkew
Target skew value for diff pair de-skewing.
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
bool m_overrideCustomRules
Type of corners for the meandered line.
void SetTargetSkewDelay(int aOpt)
static const long long int DELAY_UNCONSTRAINED
int m_spacing
Amplitude/spacing adjustment step.
Keep the router "world" - i.e.
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
std::set< OBSTACLE > OBSTACLES
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=nullptr, bool aStopAtLockedJoints=false, bool aFollowLockedSegments=false, bool aAllowSegmentSizeMismatch=true)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
int QueryColliding(const ITEM *aItem, OBSTACLES &aObstacles, const COLLISION_SEARCH_OPTIONS &aOpts=COLLISION_SEARCH_OPTIONS()) const
Find items colliding (closer than clearance) with the item aItem.
void Remove(ARC *aArc)
Remove an item from this branch.
virtual int GetPNSLayerFromBoardLayer(PCB_LAYER_ID aLayer) const =0
virtual void RemoveItem(ITEM *aItem)=0
virtual void AddItem(ITEM *aItem)=0
void SetMode(ROUTER_MODE aMode)
PLACEMENT_ALGO * Placer()
ROUTER_IFACE * GetInterface() const
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, int aSlopRadius=0)
RULE_RESOLVER * GetRuleResolver() const
bool RoutingInProgress() const
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish, bool aForceCommit)
bool Move(const VECTOR2I &aP, ITEM *aItem)
virtual int Clearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true)=0
const SHAPE_LINE_CHAIN CLine() const
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
void SetShape(SHAPE *shape)
void SetStartLayerFromPCBNew(PCB_LAYER_ID aLayer)
int GetPNSLayerFromBoardLayer(PCB_LAYER_ID aLayer) const override
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false, int aFlags=0) override
void EraseView() override
wxString GetNetName(PNS::NET_HANDLE aNet) const override
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
RAII class that sets an value at construction and resets it to the original value at destruction.
int LineDistance(const VECTOR2I &aP, bool aDetermineSide=false) const
Return the closest Euclidean distance between point aP and the line defined by the ends of segment (t...
VECTOR2I::extended_type ecoord
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
const VECTOR2I & GetArcMid() const
VECTOR2I NearestPoint(const VECTOR2I &aP) const
bool PointOnEdge(const VECTOR2I &aP, int aAccuracy=0) const
Check if point aP lies on an edge or vertex of the line chain.
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
Check if point aP lies inside a closed shape.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
int Split(const VECTOR2I &aP, bool aExact=false)
Insert the point aP belonging to one of the our segments, splitting the adjacent segment in two.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Simplify(int aTolerance=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
SHAPE * Clone() const override
Return a dynamically allocated copy of the shape.
bool OffsetLine(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, SHAPE_LINE_CHAIN &aLeft, SHAPE_LINE_CHAIN &aRight, bool aSimplify=false) const
Creates line chains aLeft and aRight offset to this line chain.
Represent a set of closed polygons.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void OffsetLineChain(const SHAPE_LINE_CHAIN &aLine, int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify)
Perform offsetting of a line chain.
int OutlineCount() const
Return the number of outlines in the set.
virtual VECTOR2I Centre() const
Compute a center-of-mass of the shape.
A name/value tuple with unique names and wxAny values.
void set_iu(const std::string &aKey, const T &aVar)
bool get_to(const std::string &aKey, T &aVar) const
std::optional< T > get_opt(const std::string &aKey) const
void set(const std::string &aKey, const T &aVar)
bool get_to_iu(const std::string &aKey, T &aVar) const
GR_TEXT_H_ALIGN_T m_Halign
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 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.
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 SetPosition(const VECTOR2I &aPos) override
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString MessageTextFromMinOptMax(const MINOPTMAX< int > &aValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
PCB_TUNING_PATTERN * m_pattern
UNLOCKER(PCB_TUNING_PATTERN *aPattern)
constexpr extended_type SquaredDistance(const VECTOR2< T > &aVector) const
Compute the squared distance between two vectors.
static constexpr extended_type ECOORD_MAX
@ ROUND_ALL_CORNERS
All angles are rounded.
#define IS_NEW
New item, just created.
#define IN_EDIT
Item currently edited.
EDA_DATA_TYPE
The type of unit.
static FILENAME_RESOLVER * resolver
a few functions useful in geometry calculations.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
TEXT_DIMS GetConstantGlyphHeight(KIGFX::GAL *aGal, int aRelativeSize=0)
Set the GAL glyph height to a constant scaled value, so that it always looks the same on screen.
Push and Shove diff pair dimensions (gap) settings dialog.
@ PNS_MODE_TUNE_DIFF_PAIR
@ PNS_MODE_TUNE_DIFF_PAIR_SKEW
Class to handle a set of BOARD_ITEMs.
static PNS::MEANDER_SIDE sideFromString(const std::string &aStr)
static LENGTH_TUNING_MODE tuningFromString(const std::string &aStr)
static std::string tuningToString(const LENGTH_TUNING_MODE aTuning)
static struct PCB_TUNING_PATTERN_DESC _PCB_TUNING_PATTERN_DESC
static LENGTH_TUNING_MODE fromPNSMode(PNS::ROUTER_MODE aRouterMode)
static PNS::MEANDER_PLACER_BASE::TUNING_STATUS statusFromString(const std::string &aStr)
static std::string sideToString(const PNS::MEANDER_SIDE aValue)
static std::string statusToString(const PNS::MEANDER_PLACER_BASE::TUNING_STATUS aStatus)
static GENERATORS_MGR::REGISTER< PCB_TUNING_PATTERN > registerMe
static PNS::LINKED_ITEM * pickSegment(PNS::ROUTER *aRouter, const VECTOR2I &aWhere, int aLayer, VECTOR2I &aPointOut, const SHAPE_LINE_CHAIN &aBaseline=SHAPE_LINE_CHAIN())
static std::optional< PNS::LINE > getPNSLine(const VECTOR2I &aStart, const VECTOR2I &aEnd, PNS::ROUTER *router, int layer, VECTOR2I &aStartOut, VECTOR2I &aEndOut)
static VECTOR2I snapToNearestTrack(const VECTOR2I &aP, BOARD *aBoard, NETINFO_ITEM *aNet, PCB_TRACK **aNearestTrack)
SCOPED_SET_RESET< DRAWING_TOOL::MODE > SCOPED_DRAW_MODE
static REGISTER_LEGACY_TUNING_PATTERN< PCB_TUNING_PATTERN > registerMeToo
#define NO_SETTER(owner, type)
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
@ PT_DEFAULT
Default property for a given type.
@ PT_SIZE
Size expressed in distance units (mm/inch)
@ PT_NET
Net selection property.
@ PT_TIME
Time expressed in ps.
constexpr double correction
#define HITTEST_THRESHOLD_PIXELS
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
PCB_TUNING_PATTERN_DESC()
bool m_useClearanceEpsilon
An abstract function object, returning a design rule (clearance, diff pair gap, etc) required between...
Hold an object colliding with another object, along with some useful data about the collision.
REGISTER_LEGACY_TUNING_PATTERN()
const SHAPE_LINE_CHAIN chain
wxString result
Test unit parsing edge cases and error handling.
double DEG2RAD(double deg)
@ NOT_USED
the 3d code uses this value
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D