mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Add a graphics handler to DRC Engine
The handler can be used to set graphical shapes to a DRC marker
This commit is contained in:
parent
346e3f4d7c
commit
5e263c9eec
@ -73,7 +73,8 @@ DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) :
|
||||
m_reportAllTrackErrors( false ),
|
||||
m_testFootprints( false ),
|
||||
m_reporter( nullptr ),
|
||||
m_progressReporter( nullptr )
|
||||
m_progressReporter( nullptr ),
|
||||
m_graphicsHandler( nullptr )
|
||||
{
|
||||
m_errorLimits.resize( DRCE_LAST + 1 );
|
||||
|
||||
|
@ -72,6 +72,9 @@ typedef std::function<void( const std::shared_ptr<DRC_ITEM>& aItem,
|
||||
int aLayer )> DRC_VIOLATION_HANDLER;
|
||||
|
||||
|
||||
typedef std::function<void( PCB_MARKER* aMarker )> DRC_GRAPHICS_HANDLER;
|
||||
|
||||
|
||||
/**
|
||||
* Design Rule Checker object that performs all the DRC tests.
|
||||
*
|
||||
@ -124,6 +127,23 @@ public:
|
||||
m_violationHandler = DRC_VIOLATION_HANDLER();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set an optional DRC graphics handler (receives a PCB_MARKER).
|
||||
*/
|
||||
void SetGraphicsHandler( DRC_GRAPHICS_HANDLER aHandler )
|
||||
{
|
||||
m_graphicsHandler = std::move( aHandler );
|
||||
}
|
||||
|
||||
void ClearGraphicsHandler() { m_graphicsHandler = DRC_GRAPHICS_HANDLER(); }
|
||||
|
||||
void GraphicsHandler( PCB_MARKER* aMarker )
|
||||
{
|
||||
if( m_graphicsHandler )
|
||||
m_graphicsHandler( aMarker );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an optional reporter for user-level progress info.
|
||||
*/
|
||||
@ -252,6 +272,8 @@ protected:
|
||||
// constraint -> rule -> provider
|
||||
std::map<DRC_CONSTRAINT_T, std::vector<DRC_ENGINE_CONSTRAINT*>*> m_constraintMap;
|
||||
|
||||
|
||||
DRC_GRAPHICS_HANDLER m_graphicsHandler;
|
||||
DRC_VIOLATION_HANDLER m_violationHandler;
|
||||
REPORTER* m_reporter;
|
||||
PROGRESS_REPORTER* m_progressReporter;
|
||||
|
@ -82,22 +82,18 @@ void DRC_TEST_PROVIDER_CLEARANCE_BASE::ShowPathDRC( const std::vector<PCB_SHAPE>
|
||||
shortestPathShapes1.push_back( s2 );
|
||||
}
|
||||
|
||||
m_violationHandlerBuffer = [aCommit, shortestPathShapes1,
|
||||
shortestPathShapes2]( const std::shared_ptr<DRC_ITEM>& aItem,
|
||||
VECTOR2I aPos, int aReportLayer )
|
||||
m_GraphicsHandlerBuffer =
|
||||
[aCommit, shortestPathShapes1, shortestPathShapes2]( PCB_MARKER* aMarker )
|
||||
{
|
||||
PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aReportLayer );
|
||||
|
||||
|
||||
if( !aCommit || !marker )
|
||||
if( !aCommit || !aMarker )
|
||||
return;
|
||||
|
||||
marker->SetShapes1( std::move( shortestPathShapes1 ) );
|
||||
marker->SetShapes2( std::move( shortestPathShapes2 ) );
|
||||
aCommit->Add( marker );
|
||||
aMarker->SetShapes1( std::move( shortestPathShapes1 ) );
|
||||
aMarker->SetShapes2( std::move( shortestPathShapes2 ) );
|
||||
aCommit->Add( aMarker );
|
||||
};
|
||||
|
||||
std::swap( m_violationHandlerBuffer, m_drcEngine->m_violationHandler );
|
||||
std::swap( m_GraphicsHandlerBuffer, m_drcEngine->m_graphicsHandler );
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +131,8 @@ void DRC_TEST_PROVIDER_CLEARANCE_BASE::ReportAndShowPathCuToCu(
|
||||
PATH_CONNECTION pc = minGc->m_path;
|
||||
ShowPathDRC( minGc->GetShapes(), pc.a1, pc.a2, aDistance );
|
||||
reportViolation( aDrce, aMarkerPos, aMarkerLayer );
|
||||
std::swap( m_violationHandlerBuffer, m_drcEngine->m_violationHandler );
|
||||
// After a ShowPathDRC() call, restore the handler
|
||||
std::swap( m_GraphicsHandlerBuffer, m_drcEngine->m_graphicsHandler );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
const VECTOR2I& aEnd, int aLength );
|
||||
|
||||
|
||||
DRC_VIOLATION_HANDLER m_violationHandlerBuffer;
|
||||
DRC_GRAPHICS_HANDLER m_GraphicsHandlerBuffer;
|
||||
};
|
||||
|
||||
|
||||
|
@ -227,7 +227,8 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage( CreepageGraph& aGraph, int aNetCod
|
||||
|
||||
this->ShowPathDRC( path, startPoint, endPoint, distance );
|
||||
reportViolation( drce, shortestPath[1]->m_path.a2, aLayer );
|
||||
std::swap( m_violationHandlerBuffer, m_drcEngine->m_violationHandler );
|
||||
// After a ShowPathDRC() call, restore the handler
|
||||
std::swap( m_GraphicsHandlerBuffer, m_drcEngine->m_graphicsHandler );
|
||||
}
|
||||
shortestPath.clear();
|
||||
|
||||
|
@ -175,6 +175,7 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aRefillZones
|
||||
[&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, int aLayer )
|
||||
{
|
||||
PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer );
|
||||
m_drcEngine->GraphicsHandler( marker );
|
||||
commit.Add( marker );
|
||||
} );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user