本文整理汇总了C++中D_PAD类的典型用法代码示例。如果您正苦于以下问题:C++ D_PAD类的具体用法?C++ D_PAD怎么用?C++ D_PAD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了D_PAD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteMarkedItems
/* Delete marked items
*/
void DeleteMarkedItems( MODULE* module )
{
if( module == NULL )
return;
D_PAD* next_pad;
BOARD* board = module->GetBoard();
for( D_PAD* pad = module->Pads(); pad; pad = next_pad )
{
next_pad = pad->Next();
if( !pad->IsSelected() )
continue;
if( board )
board->PadDelete( pad );
else
pad->DeleteStructure();
}
BOARD_ITEM* next_item;
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = next_item )
{
next_item = item->Next();
if( !item->IsSelected() )
continue;
item->DeleteStructure();
}
// Ref and value can be flagged, but cannot be deleted
ClearMarkItems( module );
}
示例2: BuildTracksCandidatesList
void TRACKS_CLEANER::buildTrackConnectionInfo()
{
BuildTracksCandidatesList( m_Brd->m_Track, NULL);
// clear flags and variables used in cleanup
for( TRACK * track = m_Brd->m_Track; track; track = track->Next() )
{
track->start = NULL;
track->end = NULL;
track->m_PadsConnected.clear();
track->SetState( START_ON_PAD|END_ON_PAD|BUSY, false );
}
// Build connections info tracks to pads
SearchTracksConnectedToPads();
for( TRACK * track = m_Brd->m_Track; track; track = track->Next() )
{
// Mark track if connected to pads
for( unsigned jj = 0; jj < track->m_PadsConnected.size(); jj++ )
{
D_PAD * pad = track->m_PadsConnected[jj];
if( pad->HitTest( track->GetStart() ) )
{
track->start = pad;
track->SetState( START_ON_PAD, true );
}
if( pad->HitTest( track->GetEnd() ) )
{
track->end = pad;
track->SetState( END_ON_PAD, true );
}
}
}
}
示例3: CopyMarkedItems
/* Copy marked items, at new position = old position + offset
*/
void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
{
if( module == NULL )
return;
// Reference and value cannot be copied, they are unique.
// Ensure they are not selected
module->Reference().ClearFlags();
module->Value().ClearFlags();
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->ClearFlags( SELECTED );
D_PAD* NewPad = new D_PAD( *pad );
NewPad->SetParent( module );
NewPad->SetFlags( SELECTED );
module->Pads().PushFront( NewPad );
if( aIncrement )
NewPad->IncrementPadName( true, true );
}
BOARD_ITEM* newItem;
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
{
if( !item->IsSelected() )
continue;
item->ClearFlags( SELECTED );
newItem = (BOARD_ITEM*)item->Clone();
newItem->SetParent( module );
newItem->SetFlags( SELECTED );
module->GraphicalItems().PushFront( newItem );
}
MoveMarkedItems( module, offset );
}
示例4: CreateNewModule
MODULE* PCB_EDIT_FRAME::CreateMuWaveBaseFootprint( const wxString& aValue,
int aTextSize, int aPadCount )
{
MODULE* module = CreateNewModule( aValue );
if( aTextSize > 0 )
{
module->Reference().SetSize( wxSize( aTextSize, aTextSize ) );
module->Reference().SetThickness( aTextSize/5 );
module->Value().SetSize( wxSize( aTextSize, aTextSize ) );
module->Value().SetThickness( aTextSize/5 );
}
// Create 2 pads used in gaps and stubs. The gap is between these 2 pads
// the stub is the pad 2
wxString Line;
int pad_num = 1;
while( aPadCount-- )
{
D_PAD* pad = new D_PAD( module );
module->Pads().PushFront( pad );
int tw = GetDesignSettings().GetCurrentTrackWidth();
pad->SetSize( wxSize( tw, tw ) );
pad->SetPosition( module->GetPosition() );
pad->SetShape( PAD_SHAPE_RECT );
pad->SetAttribute( PAD_ATTRIB_SMD );
pad->SetLayerSet( F_Cu );
Line.Printf( wxT( "%d" ), pad_num );
pad->SetPadName( Line );
pad_num++;
}
return module;
}
示例5: D_PAD
/* Add a new pad to aModule.
*/
void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
{
m_Pcb->m_Status_Pcb = 0;
aModule->SetLastEditTime();
D_PAD* pad = new D_PAD( aModule );
// Add the new pad to end of the module pad list.
aModule->Pads().PushBack( pad );
// Update the pad properties,
// and keep NETINFO_LIST::ORPHANED as net info
// which is the default when nets cannot be handled.
Import_Pad_Settings( pad, false );
pad->SetPosition( GetCrossHairPosition() );
// Set the relative pad position
// ( pad position for module orient, 0, and relative to the module position)
wxPoint pos0 = pad->GetPosition() - aModule->GetPosition();
RotatePoint( &pos0, -aModule->GetOrientation() );
pad->SetPos0( pos0 );
/* NPTH pads take empty pad number (since they can't be connected),
* other pads get incremented from the last one edited */
wxString padName;
if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
{
padName = GetNextPadName( GetDesignSettings()
.m_Pad_Master.GetPadName() );
}
pad->SetPadName( padName );
GetDesignSettings().m_Pad_Master.SetPadName( padName );
aModule->CalculateBoundingBox();
SetMsgPanel( pad );
if( draw )
m_canvas->RefreshDrawingRect( aModule->GetBoundingBox() );
}
示例6: NORMALIZE_ANGLE_POS
void MODULE::SetOrientation( double newangle )
{
double angleChange = newangle - m_Orient; // change in rotation
wxPoint pt;
NORMALIZE_ANGLE_POS( newangle );
m_Orient = newangle;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pt = pad->GetPos0();
pad->SetOrientation( pad->GetOrientation() + angleChange );
RotatePoint( &pt, m_Orient );
pad->SetPosition( GetPosition() + pt );
}
// Update of the reference and value.
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
// Displace contours and text of the footprint.
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == PCB_MODULE_EDGE_T )
{
EDGE_MODULE* edge = (EDGE_MODULE*) item;
edge->SetDrawCoord();
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
TEXTE_MODULE* text = (TEXTE_MODULE*) item;
text->SetDrawCoord();
}
}
CalculateBoundingBox();
}
示例7: Pads
/* generate pads shapes on layer aLayer as polygons,
* and adds these polygons to aCornerBuffer
* aCornerBuffer = the buffer to store polygons
* aInflateValue = an additionnal size to add to pad shapes
* aCircleToSegmentsCount = number of segments to approximate a circle
* aCorrectionFactor = the correction to apply to a circle radius
* to generate the polygon.
* if aCorrectionFactor = 1.0, the polygon is inside the circle
* the radius of circle approximated by segments is
* initial radius * aCorrectionFactor
*/
void MODULE::TransformPadsShapesWithClearanceToPolygon( LAYER_NUM aLayer,
CPOLYGONS_LIST& aCornerBuffer,
int aInflateValue,
int aCircleToSegmentsCount,
double aCorrectionFactor )
{
D_PAD* pad = Pads();
wxSize margin;
for( ; pad != NULL; pad = pad->Next() )
{
if( !pad->IsOnLayer(aLayer) )
continue;
switch( aLayer )
{
case SOLDERMASK_N_FRONT:
case SOLDERMASK_N_BACK:
margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
break;
case SOLDERPASTE_N_FRONT:
case SOLDERPASTE_N_BACK:
margin = pad->GetSolderPasteMargin();
margin.x += aInflateValue;
margin.y += aInflateValue;
break;
default:
margin.x = margin.y = aInflateValue;
break;
}
pad->BuildPadShapePolygon( aCornerBuffer, margin,
aCircleToSegmentsCount, aCorrectionFactor );
}
}
示例8: wxASSERT
void DRC::testPad2Pad()
{
std::vector<D_PAD*> sortedPads;
m_pcb->GetSortedPadListByXthenYCoord( sortedPads );
// find the max size of the pads (used to stop the test)
int max_size = 0;
for( unsigned i = 0; i < sortedPads.size(); ++i )
{
D_PAD* pad = sortedPads[i];
// GetBoundingRadius() is the radius of the minimum sized circle fully containing the pad
int radius = pad->GetBoundingRadius();
if( radius > max_size )
max_size = radius;
}
// Test the pads
D_PAD** listEnd = &sortedPads[ sortedPads.size() ];
for( unsigned i = 0; i< sortedPads.size(); ++i )
{
D_PAD* pad = sortedPads[i];
int x_limit = max_size + pad->GetClearance() +
pad->GetBoundingRadius() + pad->GetPosition().x;
if( !doPadToPadsDrc( pad, &sortedPads[i], listEnd, x_limit ) )
{
wxASSERT( m_currentMarker );
m_pcb->Add( m_currentMarker );
m_mainWindow->GetGalCanvas()->GetView()->Add( m_currentMarker );
m_currentMarker = 0;
}
}
}
示例9: KiROUND
MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern,
PCB_EDIT_FRAME* aPcbFrame, wxString& aErrorMessage )
{
/* Build a microwave inductor footprint.
* - Length Mself.lng
* - Extremities Mself.m_Start and Mself.m_End
* We must determine:
* Mself.nbrin = number of segments perpendicular to the direction
* (The coil nbrin will demicercles + 1 + 2 1 / 4 circle)
* Mself.lbrin = length of a strand
* Mself.radius = radius of rounded parts of the coil
* Mself.delta = segments extremities connection between him and the coil even
*
* The equations are
* Mself.m_Size.x = 2 * Mself.radius + Mself.lbrin
* Mself.m_Size.y * Mself.delta = 2 + 2 * Mself.nbrin * Mself.radius
* Mself.lng = 2 * Mself.delta / / connections to the coil
+ (Mself.nbrin-2) * Mself.lbrin / / length of the strands except 1st and last
+ (Mself.nbrin 1) * (PI * Mself.radius) / / length of rounded
* Mself.lbrin + / 2 - Melf.radius * 2) / / length of 1st and last bit
*
* The constraints are:
* Nbrin >= 2
* Mself.radius < Mself.m_Size.x
* Mself.m_Size.y = Mself.radius * 4 + 2 * Mself.raccord
* Mself.lbrin> Mself.radius * 2
*
* The calculation is conducted in the following way:
* Initially:
* Nbrin = 2
* Radius = 4 * m_Size.x (arbitrarily fixed value)
* Then:
* Increasing the number of segments to the desired length
* (Radius decreases if necessary)
*/
D_PAD* pad;
int ll;
wxString msg;
auto pt = inductorPattern.m_End - inductorPattern.m_Start;
int min_len = KiROUND( EuclideanNorm( pt ) );
inductorPattern.m_length = min_len;
// Enter the desired length.
msg = StringFromValue( g_UserUnit, inductorPattern.m_length );
wxTextEntryDialog dlg( nullptr, wxEmptyString, _( "Length of Trace:" ), msg );
if( dlg.ShowModal() != wxID_OK )
return nullptr; // canceled by user
msg = dlg.GetValue();
inductorPattern.m_length = ValueFromString( g_UserUnit, msg );
// Control values (ii = minimum length)
if( inductorPattern.m_length < min_len )
{
aErrorMessage = _( "Requested length < minimum length" );
return nullptr;
}
// Calculate the elements.
std::vector <wxPoint> buffer;
ll = BuildCornersList_S_Shape( buffer, inductorPattern.m_Start,
inductorPattern.m_End, inductorPattern.m_length,
inductorPattern.m_Width );
if( !ll )
{
aErrorMessage = _( "Requested length too large" );
return nullptr;
}
// Generate footprint. the value is also used as footprint name.
msg = "L";
wxTextEntryDialog cmpdlg( nullptr, wxEmptyString, _( "Component Value:" ), msg );
cmpdlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &msg ) );
if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
return nullptr; // Aborted by user
MODULE* module = aPcbFrame->CreateNewModule( msg );
// here the module is already in the BOARD, CreateNewModule() does that.
module->SetFPID( LIB_ID( wxString( "mw_inductor" ) ) );
module->SetAttributes( MOD_VIRTUAL | MOD_CMS );
module->ClearFlags();
module->SetPosition( inductorPattern.m_End );
// Generate segments
for( unsigned jj = 1; jj < buffer.size(); jj++ )
{
EDGE_MODULE* PtSegm;
PtSegm = new EDGE_MODULE( module );
PtSegm->SetStart( buffer[jj - 1] );
PtSegm->SetEnd( buffer[jj] );
PtSegm->SetWidth( inductorPattern.m_Width );
PtSegm->SetLayer( module->GetLayer() );
PtSegm->SetShape( S_SEGMENT );
PtSegm->SetStart0( PtSegm->GetStart() - module->GetPosition() );
//.........这里部分代码省略.........
示例10: Add
MODULE& MODULE::operator=( const MODULE& aOther )
{
BOARD_ITEM::operator=( aOther );
m_Pos = aOther.m_Pos;
m_fpid = aOther.m_fpid;
m_Attributs = aOther.m_Attributs;
m_ModuleStatus = aOther.m_ModuleStatus;
m_Orient = aOther.m_Orient;
m_BoundaryBox = aOther.m_BoundaryBox;
m_CntRot90 = aOther.m_CntRot90;
m_CntRot180 = aOther.m_CntRot180;
m_LastEditTime = aOther.m_LastEditTime;
m_Link = aOther.m_Link;
m_Path = aOther.m_Path; //is this correct behavior?
m_LocalClearance = aOther.m_LocalClearance;
m_LocalSolderMaskMargin = aOther.m_LocalSolderMaskMargin;
m_LocalSolderPasteMargin = aOther.m_LocalSolderPasteMargin;
m_LocalSolderPasteMarginRatio = aOther.m_LocalSolderPasteMarginRatio;
m_ZoneConnection = aOther.m_ZoneConnection;
m_ThermalWidth = aOther.m_ThermalWidth;
m_ThermalGap = aOther.m_ThermalGap;
// Copy reference and value
*m_Reference = *aOther.m_Reference;
m_Reference->SetParent( this );
*m_Value = *aOther.m_Value;
m_Value->SetParent( this );
// Copy auxiliary data: Pads
m_Pads.DeleteAll();
for( D_PAD* pad = aOther.m_Pads; pad; pad = pad->Next() )
{
Add( new D_PAD( *pad ) );
}
// Copy auxiliary data: Drawings
m_Drawings.DeleteAll();
for( BOARD_ITEM* item = aOther.m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
case PCB_MODULE_EDGE_T:
Add( static_cast<BOARD_ITEM*>( item->Clone() ) );
break;
default:
wxLogMessage( wxT( "MODULE::operator=() internal error: unknown type" ) );
break;
}
}
// Copy auxiliary data: 3D_Drawings info
m_3D_Drawings.clear();
m_3D_Drawings = aOther.m_3D_Drawings;
m_Doc = aOther.m_Doc;
m_KeyWord = aOther.m_KeyWord;
// Ensure auxiliary data is up to date
CalculateBoundingBox();
return *this;
}
示例11: GetBoard
void EDA_3D_CANVAS::buildTechLayers3DView( REPORTER* aErrorMessages, REPORTER* aActivity )
{
BOARD* pcb = GetBoard();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
// Number of segments to draw a circle using segments
const int segcountforcircle = 18;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations
// for holes and items which do not need
// a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2) );
// segments to draw a circle to build texts. Is is used only to build
// the shape of each segment of the stroke font, therefore no need to have
// many segments per circle.
const int segcountInStrokeFont = 8;
SHAPE_POLY_SET bufferPolys;
SHAPE_POLY_SET allLayerHoles; // Contains through holes, calculated only once
SHAPE_POLY_SET bufferPcbOutlines; // stores the board main outlines
// Build a polygon from edge cut items
wxString msg;
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{
if( aErrorMessages )
{
msg << wxT("\n") <<
_("Unable to calculate the board outlines.\n"
"Therefore use the board boundary box.") << wxT("\n\n");
aErrorMessages->Report( msg, REPORTER::RPT_WARNING );
}
}
// Build board holes, with no optimization of large holes shape.
buildBoardThroughHolesPolygonList( allLayerHoles, segcountLowQuality, false );
// draw graphic items, on technical layers
static const LAYER_ID teckLayerList[] = {
B_Adhes,
F_Adhes,
B_Paste,
F_Paste,
B_SilkS,
F_SilkS,
B_Mask,
F_Mask,
};
// User layers are not drawn here, only technical layers
for( LSEQ seq = LSET::AllTechMask().Seq( teckLayerList, DIM( teckLayerList ) ); seq; ++seq )
{
LAYER_ID layer = *seq;
if( !is3DLayerEnabled( layer ) )
continue;
if( layer == Edge_Cuts && isEnabled( FL_SHOW_BOARD_BODY ) )
continue;
if( aActivity )
aActivity->Report( wxString::Format( _( "Build layer %s" ), LSET::Name( layer ) ) );
bufferPolys.RemoveAllContours();
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_LINE_T:
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0, segcountforcircle, correctionFactor );
break;
case PCB_TEXT_T:
( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountLowQuality, 1.0 );
break;
default:
break;
}
}
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
if( layer == F_SilkS || layer == B_SilkS )
{
// On silk screen layers, the pad shape is only the pad outline
// never a filled shape
D_PAD* pad = module->Pads();
int linewidth = g_DrawDefaultLineThickness;
//.........这里部分代码省略.........
示例12: Millimeter2iu
void EDA_3D_CANVAS::buildBoardThroughHolesPolygonList( SHAPE_POLY_SET& allBoardHoles,
int aSegCountPerCircle, bool aOptimizeLargeCircles )
{
// hole diameter value to change seg count by circle:
int small_hole_limit = Millimeter2iu( 1.0 );
int copper_thickness = GetPrm3DVisu().GetCopperThicknessBIU();
BOARD* pcb = GetBoard();
// Build holes of through vias:
for( TRACK* track = pcb->m_Track; track; track = track->Next() )
{
if( track->Type() != PCB_VIA_T )
continue;
VIA *via = static_cast<VIA*>( track );
if( via->GetViaType() != VIA_THROUGH )
continue;
int holediameter = via->GetDrillValue();
int hole_outer_radius = (holediameter + copper_thickness) / 2;
TransformCircleToPolygon( allBoardHoles,
via->GetStart(), hole_outer_radius,
aSegCountPerCircle );
}
// Build holes of through pads:
for( MODULE* footprint = pcb->m_Modules; footprint; footprint = footprint->Next() )
{
for( D_PAD* pad = footprint->Pads(); pad; pad = pad->Next() )
{
// Calculate a factor to apply to segcount for large holes ( > 1 mm)
// (bigger pad drill size -> more segments) because holes in pads can have
// very different sizes and optimizing this segcount gives a better look
// Mainly mounting holes have a size bigger than small_hole_limit
wxSize padHole = pad->GetDrillSize();
if( ! padHole.x ) // Not drilled pad like SMD pad
continue;
// we use the hole diameter to calculate the seg count.
// for round holes, padHole.x == padHole.y
// for oblong holes, the diameter is the smaller of (padHole.x, padHole.y)
int diam = std::min( padHole.x, padHole.y );
int segcount = aSegCountPerCircle;
if( diam > small_hole_limit )
{
double segFactor = (double)diam / small_hole_limit;
segcount = (int)(aSegCountPerCircle * segFactor);
// limit segcount to 48. For a circle this is a very good approx.
if( segcount > 48 )
segcount = 48;
}
// The hole in the body is inflated by copper thickness.
int inflate = copper_thickness;
// If not plated, no copper.
if( pad->GetAttribute () == PAD_HOLE_NOT_PLATED )
inflate = 0;
pad->BuildPadDrillShapePolygon( allBoardHoles, inflate, segcount );
}
}
allBoardHoles.Simplify();
}
示例13: ImportSettingsFromMaster
void D_PAD::ImportSettingsFromMaster( const D_PAD& aMasterPad )
{
SetShape( aMasterPad.GetShape() );
SetLayerSet( aMasterPad.GetLayerSet() );
SetAttribute( aMasterPad.GetAttribute() );
// The pad orientation, for historical reasons is the
// pad rotation + parent rotation.
// So we have to manage this parent rotation
double pad_rot = aMasterPad.GetOrientation();
if( aMasterPad.GetParent() )
pad_rot -= aMasterPad.GetParent()->GetOrientation();
if( GetParent() )
pad_rot += GetParent()->GetOrientation();
SetOrientation( pad_rot );
SetSize( aMasterPad.GetSize() );
SetDelta( wxSize( 0, 0 ) );
SetOffset( aMasterPad.GetOffset() );
SetDrillSize( aMasterPad.GetDrillSize() );
SetDrillShape( aMasterPad.GetDrillShape() );
SetRoundRectRadiusRatio( aMasterPad.GetRoundRectRadiusRatio() );
switch( aMasterPad.GetShape() )
{
case PAD_SHAPE_TRAPEZOID:
SetDelta( aMasterPad.GetDelta() );
break;
case PAD_SHAPE_CIRCLE:
// ensure size.y == size.x
SetSize( wxSize( GetSize().x, GetSize().x ) );
break;
default:
;
}
switch( aMasterPad.GetAttribute() )
{
case PAD_ATTRIB_SMD:
case PAD_ATTRIB_CONN:
// These pads do not have hole (they are expected to be only on one
// external copper layer)
SetDrillSize( wxSize( 0, 0 ) );
break;
default:
;
}
// Add or remove custom pad shapes:
SetPrimitives( aMasterPad.GetPrimitives() );
SetAnchorPadShape( aMasterPad.GetAnchorPadShape() );
MergePrimitivesAsPolygon();
}
示例14: getOptimalModulePlacement
int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aDC )
{
int error = 1;
wxPoint LastPosOK;
double min_cost, curr_cost, Score;
bool TstOtherSide;
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aFrame->GetDisplayOptions();
BOARD* brd = aFrame->GetBoard();
aModule->CalculateBoundingBox();
bool showRats = displ_opts->m_Show_Module_Ratsnest;
displ_opts->m_Show_Module_Ratsnest = false;
brd->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
aFrame->SetMsgPanel( aModule );
LastPosOK = RoutingMatrix.m_BrdBox.GetOrigin();
wxPoint mod_pos = aModule->GetPosition();
EDA_RECT fpBBox = aModule->GetFootprintRect();
// Move fpBBox to have the footprint position at (0,0)
fpBBox.Move( -mod_pos );
wxPoint fpBBoxOrg = fpBBox.GetOrigin();
// Calculate the limit of the footprint position, relative
// to the routing matrix area
wxPoint xylimit = RoutingMatrix.m_BrdBox.GetEnd() - fpBBox.GetEnd();
wxPoint initialPos = RoutingMatrix.m_BrdBox.GetOrigin() - fpBBoxOrg;
// Stay on grid.
initialPos.x -= initialPos.x % RoutingMatrix.m_GridRouting;
initialPos.y -= initialPos.y % RoutingMatrix.m_GridRouting;
CurrPosition = initialPos;
// Undraw the current footprint
aModule->DrawOutlinesWhenMoving( aFrame->GetCanvas(), aDC, wxPoint( 0, 0 ) );
g_Offset_Module = mod_pos - CurrPosition;
/* Examine pads, and set TstOtherSide to true if a footprint
* has at least 1 pad through.
*/
TstOtherSide = false;
if( RoutingMatrix.m_RoutingLayersCount > 1 )
{
LSET other( aModule->GetLayer() == B_Cu ? F_Cu : B_Cu );
for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
{
if( !( pad->GetLayerSet() & other ).any() )
continue;
TstOtherSide = true;
break;
}
}
// Draw the initial bounding box position
EDA_COLOR_T color = BROWN;
fpBBox.SetOrigin( fpBBoxOrg + CurrPosition );
draw_FootprintRect(aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, color);
min_cost = -1.0;
aFrame->SetStatusText( wxT( "Score ??, pos ??" ) );
for( ; CurrPosition.x < xylimit.x; CurrPosition.x += RoutingMatrix.m_GridRouting )
{
wxYield();
if( aFrame->GetCanvas()->GetAbortRequest() )
{
if( IsOK( aFrame, _( "OK to abort?" ) ) )
{
displ_opts->m_Show_Module_Ratsnest = showRats;
return ESC;
}
else
aFrame->GetCanvas()->SetAbortRequest( false );
}
CurrPosition.y = initialPos.y;
for( ; CurrPosition.y < xylimit.y; CurrPosition.y += RoutingMatrix.m_GridRouting )
{
// Erase traces.
draw_FootprintRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, color );
fpBBox.SetOrigin( fpBBoxOrg + CurrPosition );
g_Offset_Module = mod_pos - CurrPosition;
int keepOutCost = TstModuleOnBoard( brd, aModule, TstOtherSide );
// Draw at new place
color = keepOutCost >= 0 ? BROWN : RED;
draw_FootprintRect( aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, color );
//.........这里部分代码省略.........
示例15: shape
void DRC::testTexts()
{
std::vector<wxPoint> textShape; // a buffer to store the text shape (set of segments)
std::vector<D_PAD*> padList = m_pcb->GetPads();
// Test text areas for vias, tracks and pads inside text areas
for( BOARD_ITEM* item = m_pcb->m_Drawings; item; item = item->Next() )
{
// Drc test only items on copper layers
if( ! IsCopperLayer( item->GetLayer() ) )
continue;
// only texts on copper layers are tested
if( item->Type() != PCB_TEXT_T )
continue;
textShape.clear();
// So far the bounding box makes up the text-area
TEXTE_PCB* text = (TEXTE_PCB*) item;
text->TransformTextShapeToSegmentList( textShape );
if( textShape.size() == 0 ) // Should not happen (empty text?)
continue;
for( TRACK* track = m_pcb->m_Track; track != NULL; track = track->Next() )
{
if( ! track->IsOnLayer( item->GetLayer() ) )
continue;
// Test the distance between each segment and the current track/via
int min_dist = ( track->GetWidth() + text->GetThickness() ) /2 +
track->GetClearance(NULL);
if( track->Type() == PCB_TRACE_T )
{
SEG segref( track->GetStart(), track->GetEnd() );
// Error condition: Distance between text segment and track segment is
// smaller than the clearance of the segment
for( unsigned jj = 0; jj < textShape.size(); jj += 2 )
{
SEG segtest( textShape[jj], textShape[jj+1] );
int dist = segref.Distance( segtest );
if( dist < min_dist )
{
addMarkerToPcb( fillMarker( track, text,
DRCE_TRACK_INSIDE_TEXT,
m_currentMarker ) );
m_currentMarker = nullptr;
break;
}
}
}
else if( track->Type() == PCB_VIA_T )
{
// Error condition: Distance between text segment and via is
// smaller than the clearance of the via
for( unsigned jj = 0; jj < textShape.size(); jj += 2 )
{
SEG segtest( textShape[jj], textShape[jj+1] );
if( segtest.PointCloserThan( track->GetPosition(), min_dist ) )
{
addMarkerToPcb( fillMarker( track, text,
DRCE_VIA_INSIDE_TEXT, m_currentMarker ) );
m_currentMarker = nullptr;
break;
}
}
}
}
// Test pads
for( unsigned ii = 0; ii < padList.size(); ii++ )
{
D_PAD* pad = padList[ii];
if( ! pad->IsOnLayer( item->GetLayer() ) )
continue;
wxPoint shape_pos = pad->ShapePos();
for( unsigned jj = 0; jj < textShape.size(); jj += 2 )
{
/* In order to make some calculations more easier or faster,
* pads and tracks coordinates will be made relative
* to the segment origin
*/
wxPoint origin = textShape[jj]; // origin will be the origin of other coordinates
m_segmEnd = textShape[jj+1] - origin;
wxPoint delta = m_segmEnd;
m_segmAngle = 0;
// for a non horizontal or vertical segment Compute the segment angle
// in tenths of degrees and its length
if( delta.x || delta.y ) // delta.x == delta.y == 0 for vias
{
// Compute the segment angle in 0,1 degrees
//.........这里部分代码省略.........