50 virtual bool Run()
override;
52 virtual const wxString
GetName()
const override
54 return wxT(
"angle" );
59 return wxT(
"Tests track angles" );
68 reportAux( wxT(
"Track angle violations ignored. Tests not run." ) );
74 reportAux( wxT(
"No track angle constraints found. Tests not run." ) );
81 auto checkTrackAngle =
94 SEG segment =
SEG( item->GetStart(), item->GetEnd() );
98 for(
PCB_TRACK* other : connectivity->GetConnectedTracks( item ) )
105 SEG other_segment =
SEG( other->GetStart(), other->GetEnd() );
109 if( !intersection_opt.has_value() )
114 VECTOR2I p0 = intersection_opt.value();
127 bool angle_below_90 =
false;
129 if( segment.
B == p0 )
133 else if( segment.
A != p0 )
135 angle_below_90 =
true;
138 if( other_segment.
B == p0 )
140 other_direction *= -1;
142 else if( other_segment.
A != p0 )
144 angle_below_90 =
true;
148 if( angle_below_90 && actual > 90 )
153 bool fail_min =
false;
154 bool fail_max =
false;
159 if( constraint.Value().HasMin() && actual.
AsDegrees() < constraint.Value().Min() )
165 if( constraint.Value().HasMax() && actual.
AsDegrees() > constraint.Value().Max() )
172 if( fail_min || fail_max )
175 wxString constraintName = constraint.GetName();
180 msg =
formatMsg(
_(
"(%s min angle %s; actual %s)" ),
187 msg =
formatMsg(
_(
"(%s max angle %s; actual %s)" ),
193 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
194 drcItem->SetItems( item , other );
195 drcItem->SetViolatingRule( constraint.GetParentRule() );
204 const int progressDelta = 250;
208 std::vector<std::future<bool>> returns;
214 returns.emplace_back(
tp.submit( checkTrackAngle, item ) );
217 for( std::future<bool>& ret : returns )
219 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
221 while( status != std::future_status::ready )
224 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
const TRACKS & Tracks() const
PAD * GetPad(const VECTOR2I &aPosition, LSET aLayerMask) const
Find a pad aPosition on aLayer.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
bool HasRulesForConstraintType(DRC_CONSTRAINT_T constraintID)
bool IsErrorLimitExceeded(int error_code)
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
virtual const wxString GetName() const override
DRC_TEST_PROVIDER_TRACK_ANGLE()
virtual ~DRC_TEST_PROVIDER_TRACK_ANGLE()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual const wxString GetDescription() const override
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual)
virtual bool reportPhase(const wxString &aStageName)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
void reportAux(const wxString &aMsg)
virtual void reportRuleStatistics()
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
static EDA_ANGLE Arccos(double x)
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
std::optional< VECTOR2I > OPT_VECTOR2I
BS::thread_pool thread_pool
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< double > VECTOR2D