49 virtual bool Run()
override;
51 virtual const wxString
GetName()
const override {
return wxT(
"angle" ); };
59 REPORT_AUX( wxT(
"Track angle violations ignored. Tests not run." ) );
65 REPORT_AUX( wxT(
"No track angle constraints found. Tests not run." ) );
72 auto checkTrackAngle =
85 SEG segment =
SEG( item->GetStart(), item->GetEnd() );
89 for(
PCB_TRACK* other : connectivity->GetConnectedTracks( item ) )
96 SEG other_segment =
SEG( other->GetStart(), other->GetEnd() );
100 if( !intersection_opt.has_value() )
105 VECTOR2I p0 = intersection_opt.value();
118 bool angle_below_90 =
false;
120 if( segment.
B == p0 )
124 else if( segment.
A != p0 )
126 angle_below_90 =
true;
129 if( other_segment.
B == p0 )
131 other_direction *= -1;
133 else if( other_segment.
A != p0 )
135 angle_below_90 =
true;
144 bool fail_min =
false;
145 bool fail_max =
false;
150 if( constraint.Value().HasMin() &&
actual.AsDegrees() < constraint.Value().Min() )
156 if( constraint.Value().HasMax() &&
actual.AsDegrees() > constraint.Value().Max() )
163 if( fail_min || fail_max )
166 wxString constraintName = constraint.GetName();
171 msg =
formatMsg(
_(
"(%s min angle %s; actual %s)" ),
178 msg =
formatMsg(
_(
"(%s max angle %s; actual %s)" ),
184 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS(
" " ) + msg );
185 drcItem->SetItems( item , other );
186 drcItem->SetViolatingRule( constraint.GetParentRule() );
195 const int progressDelta = 250;
199 std::vector<std::future<bool>> returns;
205 returns.emplace_back(
tp.submit( checkTrackAngle, item ) );
208 for( std::future<bool>& ret : returns )
210 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
212 while( status != std::future_status::ready )
215 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
PAD * GetPad(const VECTOR2I &aPosition, const LSET &aLayerMask) const
Find a pad aPosition on aLayer.
const TRACKS & Tracks() const
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 ~DRC_TEST_PROVIDER_TRACK_ANGLE()=default
virtual const wxString GetName() const override
DRC_TEST_PROVIDER_TRACK_ANGLE()
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
virtual bool reportPhase(const wxString &aStageName)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer, DRC_CUSTOM_MARKER_HANDLER *aCustomHandler=nullptr)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
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 constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
std::optional< VECTOR2I > OPT_VECTOR2I
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool thread_pool
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< double > VECTOR2D