87 std::map<PCB_LAYER_ID, std::set<int>> netsByLayer;
88 std::set<const BOARD_ITEM*> movingItems;
93 if( !aItem || aItem->GetNetCode() <= 0 )
98 if( aItem->IsOnLayer( layer ) )
99 netsByLayer[layer].insert( aItem->GetNetCode() );
108 movingItems.insert( item );
110 if( item->IsConnected() )
120 if( netsByLayer.empty() )
124 std::shared_ptr<DRC_ENGINE> drcEngine =
m_drcEngine;
126 for(
const auto& [layer, affectedNets] : netsByLayer )
129 auto constraintFn = [board, drcEngine, layer](
int aNetA,
int aNetB ) ->
double
143 double maxConstraint = 0.0;
145 for(
int affected : affectedNets )
147 for(
const auto& [netCode, net] :
m_board->GetNetInfo().NetsByNetcode() )
149 if( netCode <= 0 || netCode == affected )
152 maxConstraint = std::max( maxConstraint, constraintFn( affected, netCode ) );
156 if( maxConstraint <= 0 )
159 int nearMargin =
static_cast<int>( maxConstraint / 2 );
160 int margin =
static_cast<int>( maxConstraint ) + nearMargin;
162 auto engine = std::make_unique<CREEPAGE_ENGINE>( *
m_board );
164 engine->BeginInteractive( layer, affectedNets, movingItems, margin, constraintFn );
165 m_engines[layer] = { std::move( engine ), nearMargin };
191 auto t0 = std::chrono::steady_clock::now();
192 std::vector<CREEPAGE_RESULT> results;
196 std::vector<CREEPAGE_RESULT> layerResults = le.m_engine->Update( le.m_nearMargin );
197 results.insert( results.end(), layerResults.begin(), layerResults.end() );
200 double elapsedMs = std::chrono::duration<double, std::milli>(
201 std::chrono::steady_clock::now() - t0 )
205 constexpr double frameBudgetMs = 16.0;
206 m_skipFrames =
static_cast<int>( elapsedMs / frameBudgetMs );
210 const COLOR4D violationColor( 0.92, 0.18, 0.18, 1.0 );
211 const COLOR4D nearColor( 0.95, 0.62, 0.10, 0.85 );
212 const double lineWidth =
pcbIUScale.mmToIU( 0.12 );
216 m_overlay->SetStrokeColor( r.m_violation ? violationColor : nearColor );
248 le.m_engine->EndInteractive();
constexpr EDA_IU_SCALE pcbIUScale
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
std::shared_ptr< DRC_ENGINE > m_drcEngine
std::shared_ptr< KIGFX::VIEW_OVERLAY > m_overlay
std::map< PCB_LAYER_ID, LAYER_ENGINE > m_engines
CREEPAGE_OVERLAY(BOARD *aBoard, std::shared_ptr< DRC_ENGINE > aDrcEngine, KIGFX::VIEW *aView)
void Update()
Recompute and redraw at the items' current board positions.
void Start(const std::vector< BOARD_ITEM * > &aMovingItems)
Begin a drag session for the given items, on every copper layer they occupy.
void Stop()
End the session and clear the overlay.
MINOPTMAX< int > & Value()
EDA_ANGLE GetArcAngle() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
A color representation with 4 components: red, green, blue, alpha.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
static constexpr EDA_ANGLE ANGLE_0
bool m_RealtimeCreepage
Use the realtime (V2) creepage engine.
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.
Result of a single creepage query between two nets on one layer.
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
VECTOR2< int32_t > VECTOR2I