本文整理汇总了C++中D_PAD::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ D_PAD::GetSize方法的具体用法?C++ D_PAD::GetSize怎么用?C++ D_PAD::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类D_PAD
的用法示例。
在下文中一共展示了D_PAD::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_pad_testpoints
/* Extract the D356 record from the modules (pads) */
static void build_pad_testpoints( BOARD *aPcb,
std::vector <D356_RECORD>& aRecords )
{
wxPoint origin = aPcb->GetAuxOrigin();
for( MODULE *module = aPcb->m_Modules;
module; module = module->Next() )
{
for( D_PAD *pad = module->Pads(); pad; pad = pad->Next() )
{
D356_RECORD rk;
rk.access = compute_pad_access_code( aPcb, pad->GetLayerSet() );
// It could be a mask only pad, we only handle pads with copper here
if( rk.access != -1 )
{
rk.netname = pad->GetNetname();
rk.refdes = module->GetReference();
pad->StringPadName( rk.pin );
rk.midpoint = false; // XXX MAYBE need to be computed (how?)
const wxSize& drill = pad->GetDrillSize();
rk.drill = std::min( drill.x, drill.y );
rk.hole = (rk.drill != 0);
rk.smd = pad->GetAttribute() == PAD_ATTRIB_SMD;
rk.mechanical = (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED);
rk.x_location = pad->GetPosition().x - origin.x;
rk.y_location = origin.y - pad->GetPosition().y;
rk.x_size = pad->GetSize().x;
// Rule: round pads have y = 0
if( pad->GetShape() == PAD_SHAPE_CIRCLE )
rk.y_size = 0;
else
rk.y_size = pad->GetSize().y;
rk.rotation = -KiROUND( pad->GetOrientation() ) / 10;
if( rk.rotation < 0 ) rk.rotation += 360;
// the value indicates which sides are *not* accessible
rk.soldermask = 3;
if( pad->GetLayerSet()[F_Mask] )
rk.soldermask &= ~1;
if( pad->GetLayerSet()[B_Mask] )
rk.soldermask &= ~2;
aRecords.push_back( rk );
}
}
}
}
示例2: 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();
}
示例3: TransformPadsShapesWithClearanceToPolygon
void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aMaxError,
bool aSkipNPTHPadsWihNoCopper ) const
{
D_PAD* pad = PadsList();
wxSize margin;
for( ; pad != NULL; pad = pad->Next() )
{
if( aLayer != UNDEFINED_LAYER && !pad->IsOnLayer(aLayer) )
continue;
// NPTH pads are not drawn on layers if the shape size and pos is the same
// as their hole:
if( aSkipNPTHPadsWihNoCopper && pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
{
if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
{
switch( pad->GetShape() )
{
case PAD_SHAPE_CIRCLE:
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
continue;
break;
case PAD_SHAPE_OVAL:
if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
continue;
break;
default:
break;
}
}
}
switch( aLayer )
{
case F_Mask:
case B_Mask:
margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
break;
case F_Paste:
case B_Paste:
margin = pad->GetSolderPasteMargin();
margin.x += aInflateValue;
margin.y += aInflateValue;
break;
default:
margin.x = margin.y = aInflateValue;
break;
}
pad->BuildPadShapePolygon( aCornerBuffer, margin );
}
}
示例4: PlotDrillMarks
void BRDITEMS_PLOTTER::PlotDrillMarks()
{
/* If small drills marks were requested prepare a clamp value to pass
to the helper function */
int small_drill = (GetDrillMarksType() == PCB_PLOT_PARAMS::SMALL_DRILL_SHAPE) ?
SMALL_DRILL : 0;
/* In the filled trace mode drill marks are drawn white-on-black to scrape
the underlying pad. This works only for drivers supporting color change,
obviously... it means that:
- PS, SVG and PDF output is correct (i.e. you have a 'donut' pad)
- In HPGL you can't see them
- In gerbers you can't see them, too. This is arguably the right thing to
do since having drill marks and high speed drill stations is a sure
recipe for broken tools and angry manufacturers. If you *really* want them
you could start a layer with negative polarity to scrape the film.
- In DXF they go into the 'WHITE' layer. This could be useful.
*/
if( GetMode() == FILLED )
m_plotter->SetColor( WHITE );
for( TRACK *pts = m_board->m_Track; pts != NULL; pts = pts->Next() )
{
const VIA* via = dyn_cast<const VIA*>( pts );
if( via )
plotOneDrillMark( PAD_DRILL_CIRCLE, via->GetStart(),
wxSize( via->GetDrillValue(), 0 ),
wxSize( via->GetWidth(), 0 ), 0, small_drill );
}
for( MODULE *Module = m_board->m_Modules; Module != NULL; Module = Module->Next() )
{
for( D_PAD *pad = Module->Pads(); pad != NULL; pad = pad->Next() )
{
if( pad->GetDrillSize().x == 0 )
continue;
plotOneDrillMark( pad->GetDrillShape(),
pad->GetPosition(), pad->GetDrillSize(),
pad->GetSize(), pad->GetOrientation(),
small_drill );
}
}
if( GetMode() == FILLED )
m_plotter->SetColor( GetColor() );
}
示例5: parseMODULE
//.........这里部分代码省略.........
parseInt( parameters[7], conv_unit ) );
}
int orientation = parseInt( parameters[paramCnt-4], 1.0 );
module->Reference().SetOrientation( (orientation % 2) ? 900 : 0 );
// Calculate size: default height is 40 mils, width 30 mil.
// real size is: default * ibuf[idx+3] / 100 (size in gpcb is given in percent of default size
int thsize = parseInt( parameters[paramCnt-3], TEXT_DEFAULT_SIZE ) / 100;
thsize = std::max( (int)( 5 * IU_PER_MILS ), thsize ); // Ensure a minimal size = 5 mils
int twsize = thsize * 30 / 40;
int thickness = thsize / 8;
// gEDA/pcb aligns top/left, not pcbnew's default, center/center.
// Compensate for this by shifting the insertion point instead of the
// aligment, because alignment isn't changeable in the GUI.
textPos.x = textPos.x + twsize * module->GetReference().Len() / 2;
textPos.y += thsize / 2;
// gEDA/pcb draws a bit too low/left, while pcbnew draws a bit too
// high/right. Compensate for similar appearance.
textPos.x -= thsize / 10;
textPos.y += thsize / 2;
module->Reference().SetTextPosition( textPos );
module->Reference().SetPos0( textPos );
module->Reference().SetSize( wxSize( twsize, thsize ) );
module->Reference().SetThickness( thickness );
// gEDA/pcb shows only one of value/reference/description at a time. Which
// one is selectable by a global menu setting. pcbnew needs reference as
// well as value visible, so place the value right below the reference.
module->Value().SetOrientation( module->Reference().GetOrientation() );
module->Value().SetSize( module->Reference().GetSize() );
module->Value().SetThickness( module->Reference().GetThickness() );
textPos.y += thsize * 13 / 10; // 130% line height
module->Value().SetTextPosition( textPos );
module->Value().SetPos0( textPos );
while( aLineReader->ReadLine() )
{
parameters.Clear();
parseParameters( parameters, aLineReader );
if( parameters.IsEmpty() || parameters[0] == wxT( "(" ) )
continue;
if( parameters[0] == wxT( ")" ) )
break;
paramCnt = parameters.GetCount();
// Test units value for a string line param (more than 3 parameters : ident [ xx ] )
if( paramCnt > 3 )
{
if( parameters[1] == wxT( "(" ) )
conv_unit = OLD_GPCB_UNIT_CONV;
else
conv_unit = NEW_GPCB_UNIT_CONV;
}
wxLogTrace( traceFootprintLibrary, wxT( "%s parameter count = %d." ),
GetChars( parameters[0] ), paramCnt );
// Parse a line with format: ElementLine [X1 Y1 X2 Y2 Thickness]
if( parameters[0].CmpNoCase( wxT( "ElementLine" ) ) == 0 )
示例6: PadPropertiesAccept
void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
{
if( !padValuesOK() )
return;
bool rastnestIsChanged = false;
int isign = m_isFlipped ? -1 : 1;
transferDataToPad( m_padMaster );
// m_padMaster is a pattern: ensure there is no net for this pad:
m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
if( m_currentPad ) // Set current Pad parameters
{
wxSize size;
MODULE* module = m_currentPad->GetParent();
m_parent->SaveCopyInUndoList( module, UR_CHANGED );
module->SetLastEditTime();
// redraw the area where the pad was, without pad (delete pad on screen)
m_currentPad->SetFlags( DO_NOT_DRAW );
m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
m_currentPad->ClearFlags( DO_NOT_DRAW );
// Update values
m_currentPad->SetShape( m_padMaster->GetShape() );
m_currentPad->SetAttribute( m_padMaster->GetAttribute() );
if( m_currentPad->GetPosition() != m_padMaster->GetPosition() )
{
m_currentPad->SetPosition( m_padMaster->GetPosition() );
rastnestIsChanged = true;
}
// compute the pos 0 value, i.e. pad position for module with orientation = 0
// i.e. relative to module origin (module position)
wxPoint pt = m_currentPad->GetPosition() - module->GetPosition();
RotatePoint( &pt, -module->GetOrientation() );
m_currentPad->SetPos0( pt );
m_currentPad->SetOrientation( m_padMaster->GetOrientation() * isign + module->GetOrientation() );
m_currentPad->SetSize( m_padMaster->GetSize() );
size = m_padMaster->GetDelta();
size.y *= isign;
m_currentPad->SetDelta( size );
m_currentPad->SetDrillSize( m_padMaster->GetDrillSize() );
m_currentPad->SetDrillShape( m_padMaster->GetDrillShape() );
wxPoint offset = m_padMaster->GetOffset();
offset.y *= isign;
m_currentPad->SetOffset( offset );
m_currentPad->SetPadToDieLength( m_padMaster->GetPadToDieLength() );
if( m_currentPad->GetLayerSet() != m_padMaster->GetLayerSet() )
{
rastnestIsChanged = true;
m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() );
}
if( m_isFlipped )
m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
m_currentPad->SetPadName( m_padMaster->GetPadName() );
wxString padNetname;
// For PAD_HOLE_NOT_PLATED, ensure there is no net name selected
if( m_padMaster->GetAttribute() != PAD_HOLE_NOT_PLATED )
padNetname = m_PadNetNameCtrl->GetValue();
if( m_currentPad->GetNetname() != padNetname )
{
const NETINFO_ITEM* netinfo = m_board->FindNet( padNetname );
if( !padNetname.IsEmpty() && netinfo == NULL )
{
DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
}
else
{
rastnestIsChanged = true;
m_currentPad->SetNetCode( netinfo->GetNet() );
}
}
m_currentPad->SetLocalClearance( m_padMaster->GetLocalClearance() );
m_currentPad->SetLocalSolderMaskMargin( m_padMaster->GetLocalSolderMaskMargin() );
m_currentPad->SetLocalSolderPasteMargin( m_padMaster->GetLocalSolderPasteMargin() );
m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster->GetLocalSolderPasteMarginRatio() );
m_currentPad->SetZoneConnection( m_padMaster->GetZoneConnection() );
m_currentPad->SetThermalWidth( m_padMaster->GetThermalWidth() );
m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
//.........这里部分代码省略.........
示例7: padValuesOK
// test if all values are acceptable for the pad
bool DIALOG_PAD_PROPERTIES::padValuesOK()
{
bool error = transferDataToPad( m_dummyPad );
wxArrayString error_msgs;
wxString msg;
// Test for incorrect values
if( (m_dummyPad->GetSize().x < m_dummyPad->GetDrillSize().x) ||
(m_dummyPad->GetSize().y < m_dummyPad->GetDrillSize().y) )
{
error_msgs.Add( _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
}
LSET padlayers_mask = m_dummyPad->GetLayerSet();
if( padlayers_mask == 0 )
error_msgs.Add( _( "Error: pad has no layer" ) );
if( !padlayers_mask[F_Cu] && !padlayers_mask[B_Cu] )
{
if( m_dummyPad->GetDrillSize().x || m_dummyPad->GetDrillSize().y )
{
// Note: he message is shown in an HTML window
msg = _( "Error: the pad is not on a copper layer and has a hole" );
if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
{
msg += wxT("<br><br><i>");
msg += _( "For NPTH pad, set pad size value to pad drill value,"
" if you do not want this pad plotted in gerber files"
);
}
error_msgs.Add( msg );
}
}
wxPoint max_size;
max_size.x = std::abs( m_dummyPad->GetOffset().x );
max_size.y = std::abs( m_dummyPad->GetOffset().y );
max_size.x += m_dummyPad->GetDrillSize().x / 2;
max_size.y += m_dummyPad->GetDrillSize().y / 2;
if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||
( m_dummyPad->GetSize().y / 2 < max_size.y ) )
{
error_msgs.Add( _( "Incorrect value for pad offset" ) );
}
if( error )
{
error_msgs.Add( _( "Too large value for pad delta size" ) );
}
switch( m_dummyPad->GetAttribute() )
{
case PAD_HOLE_NOT_PLATED: // Not plated, but through hole, a hole is expected
case PAD_STANDARD : // Pad through hole, a hole is also expected
if( m_dummyPad->GetDrillSize().x <= 0 )
error_msgs.Add( _( "Error: Through hole pad: drill diameter set to 0" ) );
break;
case PAD_CONN: // Connector pads are smd pads, just they do not have solder paste.
if( padlayers_mask[B_Paste] || padlayers_mask[F_Paste] )
error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n"
"Use SMD pads instead" ) );
// Fall trough
case PAD_SMD: // SMD and Connector pads (One external copper layer only)
/*
if( padlayers_mask[B_Cu] && padlayers_mask[F_Cu] )
error_msgs.Add( _( "Error: only one copper layer allowed for SMD or Connector pads" ) );
*/
break;
}
if( error_msgs.GetCount() )
{
HTML_MESSAGE_BOX dlg( this, _("Pad setup errors list" ) );
dlg.ListSet( error_msgs );
dlg.ShowModal();
}
return error_msgs.GetCount() == 0;
}
示例8: initValues
void DIALOG_PAD_PROPERTIES::initValues()
{
wxString msg;
double angle;
// Disable pad net name wxTextCtrl if the caller is the footprint editor
// because nets are living only in the board managed by the board editor
m_canEditNetName = m_parent->IsType( FRAME_PCB );
// Setup layers names from board
// Should be made first, before calling m_rbCopperLayersSel->SetSelection()
m_rbCopperLayersSel->SetString( 0, m_board->GetLayerName( F_Cu ) );
m_rbCopperLayersSel->SetString( 1, m_board->GetLayerName( B_Cu ) );
m_PadLayerAdhCmp->SetLabel( m_board->GetLayerName( F_Adhes ) );
m_PadLayerAdhCu->SetLabel( m_board->GetLayerName( B_Adhes ) );
m_PadLayerPateCmp->SetLabel( m_board->GetLayerName( F_Paste ) );
m_PadLayerPateCu->SetLabel( m_board->GetLayerName( B_Paste ) );
m_PadLayerSilkCmp->SetLabel( m_board->GetLayerName( F_SilkS ) );
m_PadLayerSilkCu->SetLabel( m_board->GetLayerName( B_SilkS ) );
m_PadLayerMaskCmp->SetLabel( m_board->GetLayerName( F_Mask ) );
m_PadLayerMaskCu->SetLabel( m_board->GetLayerName( B_Mask ) );
m_PadLayerECO1->SetLabel( m_board->GetLayerName( Eco1_User ) );
m_PadLayerECO2->SetLabel( m_board->GetLayerName( Eco2_User ) );
m_PadLayerDraft->SetLabel( m_board->GetLayerName( Dwgs_User ) );
m_isFlipped = false;
if( m_currentPad )
{
MODULE* module = m_currentPad->GetParent();
if( module->GetLayer() == B_Cu )
{
m_isFlipped = true;
m_staticModuleSideValue->SetLabel( _( "Back side (footprint is mirrored)" ) );
}
msg.Printf( wxT( "%.1f" ), module->GetOrientation() / 10.0 );
m_staticModuleRotValue->SetLabel( msg );
}
if( m_isFlipped )
{
wxPoint pt = m_dummyPad->GetOffset();
NEGATE( pt.y );
m_dummyPad->SetOffset( pt );
wxSize sz = m_dummyPad->GetDelta();
NEGATE( sz.y );
m_dummyPad->SetDelta( sz );
// flip pad's layers
m_dummyPad->SetLayerSet( FlipLayerMask( m_dummyPad->GetLayerSet() ) );
}
m_staticTextWarningPadFlipped->Show(m_isFlipped);
m_PadNumCtrl->SetValue( m_dummyPad->GetPadName() );
m_PadNetNameCtrl->SetValue( m_dummyPad->GetNetname() );
// Display current unit name in dialog:
m_PadPosX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadPosY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadDrill_X_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadDrill_Y_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeSizeX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeSizeY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeOffsetX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeOffsetY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeDelta_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadLengthDie_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
// Display current pad masks clearances units
m_NetClearanceUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_SolderMaskMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_ThermalWidthUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_ThermalGapUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
// Display current pad parameters units:
PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x );
PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y );
PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x );
PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y );
PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x );
PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y );
PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x );
PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->GetOffset().y );
if( m_dummyPad->GetDelta().x )
{
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x );
m_trapDeltaDirChoice->SetSelection( 0 );
}
else
//.........这里部分代码省略.........
示例9: OnPaintShowPanel
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelShowPad );
PAD_DRAWINFO drawInfo;
EDA_COLOR_T color = BLACK;
if( m_dummyPad->GetLayerSet()[F_Cu] )
{
color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
}
if( m_dummyPad->GetLayerSet()[B_Cu] )
{
color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
}
// What could happen: the pad color is *actually* black, or no
// copper was selected
if( color == BLACK )
color = LIGHTGRAY;
drawInfo.m_Color = color;
drawInfo.m_HoleColor = DARKGRAY;
drawInfo.m_Offset = m_dummyPad->GetPosition();
drawInfo.m_Display_padnum = true;
drawInfo.m_Display_netname = true;
if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
drawInfo.m_ShowNotPlatedHole = true;
// Shows the local pad clearance
drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();
wxSize dc_size = dc.GetSize();
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Calculate a suitable scale to fit the available draw area
int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y);
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double scale = (double) dc_size.x / dim;
dim = m_dummyPad->GetSize().y + std::abs( m_dummyPad->GetDelta().x);
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double altscale = (double) dc_size.y / dim;
scale = std::min( scale, altscale );
// Give a margin
scale *= 0.7;
dc.SetUserScale( scale, scale );
GRResetPenAndBrush( &dc );
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
// Draw X and Y axis.
// this is particularly useful to show the reference position of pads
// with offset and no hole
GRLine( NULL, &dc, -dim, 0, dim, 0, 0, BLUE ); // X axis
GRLine( NULL, &dc, 0, -dim, 0, dim, 0, BLUE ); // Y axis
event.Skip();
}
示例10: GlobalChange_PadSettings
//.........这里部分代码省略.........
if( saveMe )
{
ITEM_PICKER itemWrapper( module, UR_CHANGED );
itemsList.PushItem( itemWrapper );
}
}
SaveCopyInUndoList( itemsList, UR_CHANGED );
}
// Update the current module and same others modules if requested.
for( module = m_Pcb->m_Modules; module; module = module->Next() )
{
if( !aSameFootprints && (module != Module_Ref) )
continue;
if( module->GetFPID() != Module_Ref->GetFPID() )
continue;
// Erase module on screen
if( aRedraw )
{
module->SetFlags( DO_NOT_DRAW );
m_canvas->RefreshDrawingRect( module->GetBoundingBox() );
module->ClearFlags( DO_NOT_DRAW );
}
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{
// Filters changes prohibited.
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) )
continue;
if( aPadOrientFilter && (pad->GetOrientation() - module->GetOrientation()) != pad_orient )
continue;
if( aPadLayerFilter )
{
if( pad->GetLayerSet() != aPad->GetLayerSet() )
continue;
else
m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK);
}
// Change characteristics:
pad->SetAttribute( aPad->GetAttribute() );
pad->SetShape( aPad->GetShape() );
pad->SetLayerSet( aPad->GetLayerSet() );
pad->SetSize( aPad->GetSize() );
pad->SetDelta( aPad->GetDelta() );
pad->SetOffset( aPad->GetOffset() );
pad->SetDrillSize( aPad->GetDrillSize() );
pad->SetDrillShape( aPad->GetDrillShape() );
pad->SetOrientation( pad_orient + module->GetOrientation() );
// copy also local mask margins, because these parameters usually depend on
// pad sizes and layers
pad->SetLocalSolderMaskMargin( aPad->GetLocalSolderMaskMargin() );
pad->SetLocalSolderPasteMargin( aPad->GetLocalSolderPasteMargin() );
pad->SetLocalSolderPasteMarginRatio( aPad->GetLocalSolderPasteMarginRatio() );
if( pad->GetShape() != PAD_TRAPEZOID )
{
pad->SetDelta( wxSize( 0, 0 ) );
}
if( pad->GetShape() == PAD_CIRCLE )
{
// Ensure pad size.y = pad size.x
int size = pad->GetSize().x;
pad->SetSize( wxSize( size, size ) );
}
switch( pad->GetAttribute() )
{
case PAD_SMD:
case PAD_CONN:
pad->SetDrillSize( wxSize( 0, 0 ) );
pad->SetOffset( wxPoint( 0, 0 ) );
break;
default:
break;
}
}
module->CalculateBoundingBox();
if( aRedraw )
m_canvas->RefreshDrawingRect( module->GetBoundingBox() );
}
OnModify();
}
示例11: Create_MuWaveComponent
MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
{
int oX;
D_PAD* pad;
MODULE* module;
wxString msg, cmp_name;
int pad_count = 2;
int angle = 0;
// Ref and value text size (O = use board default value.
// will be set to a value depending on the footprint size, if possible
int text_size = 0;
// Enter the size of the gap or stub
int gap_size = GetDesignSettings().GetCurrentTrackWidth();
switch( shape_type )
{
case 0:
msg = _( "Gap" );
cmp_name = wxT( "muwave_gap" );
text_size = gap_size;
break;
case 1:
msg = _( "Stub" );
cmp_name = wxT( "muwave_stub" );
text_size = gap_size;
pad_count = 2;
break;
case 2:
msg = _( "Arc Stub" );
cmp_name = wxT( "muwave_arcstub" );
pad_count = 1;
break;
default:
msg = wxT( "???" );
break;
}
wxString value = StringFromValue( g_UserUnit, gap_size );
wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value );
if( dlg.ShowModal() != wxID_OK )
{
m_canvas->MoveCursorToCrossHair();
return NULL; // cancelled by user
}
value = dlg.GetValue();
gap_size = ValueFromString( g_UserUnit, value );
bool abort = false;
if( shape_type == 2 )
{
double fcoeff = 10.0, fval;
msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
wxTextEntryDialog angledlg( this, _( "Angle in degrees:" ),
_( "Create microwave module" ), msg );
if( angledlg.ShowModal() != wxID_OK )
{
m_canvas->MoveCursorToCrossHair();
return NULL; // cancelled by user
}
msg = angledlg.GetValue();
if( !msg.ToDouble( &fval ) )
{
DisplayError( this, _( "Incorrect number, abort" ) );
abort = true;
}
angle = std::abs( KiROUND( fval * fcoeff ) );
if( angle > 1800 )
angle = 1800;
}
if( abort )
{
m_canvas->MoveCursorToCrossHair();
return NULL;
}
module = CreateMuWaveBaseFootprint( cmp_name, text_size, pad_count );
pad = module->Pads();
switch( shape_type )
{
case 0: //Gap :
oX = -( gap_size + pad->GetSize().x ) / 2;
pad->SetX0( oX );
pad->SetX( pad->GetPos0().x + pad->GetPosition().x );
pad = pad->Next();
//.........这里部分代码省略.........
示例12: CreateThermalReliefPadPolygon
/*
* Note 1: polygons are drawm using outlines witk a thickness = aMinThicknessValue
* so shapes must take in account this outline thickness
*
* Note 2:
* Trapezoidal pads are not considered here because they are very special case
* and are used in microwave applications and they *DO NOT* have a thermal relief that
* change the shape by creating stubs and destroy their properties.
*/
void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer,
const D_PAD& aPad,
int aThermalGap,
int aCopperThickness,
int aMinThicknessValue,
int aError,
double aThermalRot )
{
wxPoint corner, corner_end;
wxSize copper_thickness;
wxPoint padShapePos = aPad.ShapePos(); // Note: for pad having a shape offset,
// the pad position is NOT the shape position
/* Keep in account the polygon outline thickness
* aThermalGap must be increased by aMinThicknessValue/2 because drawing external outline
* with a thickness of aMinThicknessValue will reduce gap by aMinThicknessValue/2
*/
aThermalGap += aMinThicknessValue / 2;
/* Keep in account the polygon outline thickness
* copper_thickness must be decreased by aMinThicknessValue because drawing outlines
* with a thickness of aMinThicknessValue will increase real thickness by aMinThicknessValue
*/
int dx = aPad.GetSize().x / 2;
int dy = aPad.GetSize().y / 2;
copper_thickness.x = std::min( aPad.GetSize().x, aCopperThickness ) - aMinThicknessValue;
copper_thickness.y = std::min( aPad.GetSize().y, aCopperThickness ) - aMinThicknessValue;
if( copper_thickness.x < 0 )
copper_thickness.x = 0;
if( copper_thickness.y < 0 )
copper_thickness.y = 0;
switch( aPad.GetShape() )
{
case PAD_SHAPE_CIRCLE: // Add 4 similar holes
{
/* we create 4 copper holes and put them in position 1, 2, 3 and 4
* here is the area of the rectangular pad + its thermal gap
* the 4 copper holes remove the copper in order to create the thermal gap
* 4 ------ 1
* | |
* | |
* | |
* | |
* 3 ------ 2
* holes 2, 3, 4 are the same as hole 1, rotated 90, 180, 270 deg
*/
// Build the hole pattern, for the hole in the X >0, Y > 0 plane:
// The pattern roughtly is a 90 deg arc pie
std::vector <wxPoint> corners_buffer;
int numSegs = std::max( GetArcToSegmentCount( dx + aThermalGap, aError, 360.0 ), 6 );
double correction = GetCircletoPolyCorrectionFactor( numSegs );
double delta = 3600.0 / numSegs;
// Radius of outer arcs of the shape corrected for arc approximation by lines
int outer_radius = KiROUND( ( dx + aThermalGap ) * correction );
// Crosspoint of thermal spoke sides, the first point of polygon buffer
corners_buffer.push_back( wxPoint( copper_thickness.x / 2, copper_thickness.y / 2 ) );
// Add an intermediate point on spoke sides, to allow a > 90 deg angle between side
// and first seg of arc approx
corner.x = copper_thickness.x / 2;
int y = outer_radius - (aThermalGap / 4);
corner.y = KiROUND( sqrt( ( (double) y * y - (double) corner.x * corner.x ) ) );
if( aThermalRot != 0 )
corners_buffer.push_back( corner );
// calculate the starting point of the outter arc
corner.x = copper_thickness.x / 2;
corner.y = KiROUND( sqrt( ( (double) outer_radius * outer_radius ) -
( (double) corner.x * corner.x ) ) );
RotatePoint( &corner, 90 ); // 9 degrees is the spoke fillet size
// calculate the ending point of the outer arc
corner_end.x = corner.y;
corner_end.y = corner.x;
// calculate intermediate points (y coordinate from corner.y to corner_end.y
while( (corner.y > corner_end.y) && (corner.x < corner_end.x) )
{
corners_buffer.push_back( corner );
RotatePoint( &corner, delta );
}
//.........这里部分代码省略.........
示例13: padValuesOK
// test if all values are acceptable for the pad
bool DIALOG_PAD_PROPERTIES::padValuesOK()
{
bool error = transferDataToPad( m_dummyPad );
wxArrayString error_msgs;
wxString msg;
// Test for incorrect values
if( (m_dummyPad->GetSize().x < m_dummyPad->GetDrillSize().x) ||
(m_dummyPad->GetSize().y < m_dummyPad->GetDrillSize().y) )
{
error_msgs.Add( _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
}
LAYER_MSK padlayers_mask = m_dummyPad->GetLayerMask();
if( ( padlayers_mask == 0 ) && ( m_dummyPad->GetAttribute() != PAD_HOLE_NOT_PLATED ) )
error_msgs.Add( _( "Error: pad has no layer and is not a mechanical pad" ) );
padlayers_mask &= (LAYER_BACK | LAYER_FRONT);
if( padlayers_mask == 0 )
{
if( m_dummyPad->GetDrillSize().x || m_dummyPad->GetDrillSize().y )
{
msg = _( "Error: pad is not on a copper layer and has a hole" );
if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
{
msg += wxT("\n");
msg += _( "For NPTH pad, set pad drill value to pad size value,\n"
"if you do not want this pad plotted in gerber files"
);
}
error_msgs.Add( msg );
}
}
wxPoint max_size;
max_size.x = std::abs( m_dummyPad->GetOffset().x );
max_size.y = std::abs( m_dummyPad->GetOffset().y );
max_size.x += m_dummyPad->GetDrillSize().x / 2;
max_size.y += m_dummyPad->GetDrillSize().y / 2;
if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||
( m_dummyPad->GetSize().y / 2 < max_size.y ) )
{
error_msgs.Add( _( "Incorrect value for pad offset" ) );
}
if( error )
{
error_msgs.Add( _( "Too large value for pad delta size" ) );
}
switch( m_dummyPad->GetAttribute() )
{
case PAD_STANDARD : // Pad through hole, a hole is expected
if( m_dummyPad->GetDrillSize().x <= 0 )
error_msgs.Add( _( "Incorrect value for pad drill (too small value)" ) );
break;
case PAD_SMD: // SMD and Connector pads (One external copper layer only)
if( (padlayers_mask & LAYER_BACK) && (padlayers_mask & LAYER_FRONT) )
error_msgs.Add( _( "Error: only one copper layer allowed for this pad" ) );
break;
case PAD_CONN: // connectors can have pads on "All" Cu layers.
break;
case PAD_HOLE_NOT_PLATED: // Not plated
break;
}
if( error_msgs.GetCount() )
{
HTML_MESSAGE_BOX dlg( this, _("Pad setup errors list" ) );
dlg.ListSet( error_msgs );
dlg.ShowModal();
}
return error_msgs.GetCount() == 0;
}
示例14: OnPaintShowPanel
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelShowPad );
PAD_DRAWINFO drawInfo;
EDA_COLOR_T color = BLACK;
if( m_dummyPad->GetLayerSet()[F_Cu] )
{
color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
}
if( m_dummyPad->GetLayerSet()[B_Cu] )
{
color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
}
// What could happen: the pad color is *actually* black, or no
// copper was selected
if( color == BLACK )
color = LIGHTGRAY;
drawInfo.m_Color = color;
drawInfo.m_HoleColor = DARKGRAY;
drawInfo.m_Offset = m_dummyPad->GetPosition();
drawInfo.m_Display_padnum = true;
drawInfo.m_Display_netname = true;
if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
drawInfo.m_ShowNotPlatedHole = true;
// Shows the local pad clearance
drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();
wxSize dc_size = dc.GetSize();
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Calculate a suitable scale to fit the available draw area
int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y );
// Invalid x size. User could enter zero, or have deleted all text prior to
// entering a new value; this is also treated as zero. If dim is left at
// zero, the drawing scale is zero and we get a crash.
if( dim == 0 )
{
// If drill size has been set, use that. Otherwise default to 1mm.
dim = m_dummyPad->GetDrillSize().x;
if( dim == 0 )
dim = 1000000;
}
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double scale = (double) dc_size.x / dim;
// If the pad is a circle, use the x size here instead.
int ysize;
if( m_dummyPad->GetShape() == PAD_CIRCLE )
ysize = m_dummyPad->GetSize().x;
else
ysize = m_dummyPad->GetSize().y;
dim = ysize + std::abs( m_dummyPad->GetDelta().x );
// Invalid y size. See note about x size above.
if( dim == 0 )
{
dim = m_dummyPad->GetDrillSize().y;
if( dim == 0 )
dim = 1000000;
}
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double altscale = (double) dc_size.y / dim;
scale = std::min( scale, altscale );
// Give a margin
scale *= 0.7;
dc.SetUserScale( scale, scale );
GRResetPenAndBrush( &dc );
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
// Draw X and Y axis.
// this is particularly useful to show the reference position of pads
// with offset and no hole
GRLine( NULL, &dc, -dim, 0, dim, 0, 0, BLUE ); // X axis
GRLine( NULL, &dc, 0, -dim, 0, dim, 0, BLUE ); // Y axis
event.Skip();
}
示例15: CreatePadsShapesSection
// Emit PADS and PADSTACKS. They are sorted and emitted uniquely.
// Via name is synthesized from their attributes, pads are numbered
static void CreatePadsShapesSection( FILE* aFile, BOARD* aPcb )
{
std::vector<D_PAD*> pads;
std::vector<D_PAD*> padstacks;
std::vector<VIA*> vias;
std::vector<VIA*> viastacks;
padstacks.resize( 1 ); // We count pads from 1
// The master layermask (i.e. the enabled layers) for padstack generation
LSET master_layermask = aPcb->GetDesignSettings().GetEnabledLayers();
int cu_count = aPcb->GetCopperLayerCount();
fputs( "$PADS\n", aFile );
// Enumerate and sort the pads
if( aPcb->GetPadCount() > 0 )
{
pads = aPcb->GetPads();
qsort( &pads[0], aPcb->GetPadCount(), sizeof( D_PAD* ),
PadListSortByShape );
}
// The same for vias
for( VIA* via = GetFirstVia( aPcb->m_Track ); via;
via = GetFirstVia( via->Next() ) )
{
vias.push_back( via );
}
qsort( &vias[0], vias.size(), sizeof(VIA*), ViaSort );
// Emit vias pads
TRACK* old_via = 0;
for( unsigned i = 0; i < vias.size(); i++ )
{
VIA* via = vias[i];
if( old_via && 0 == ViaSort( &old_via, &via ) )
continue;
old_via = via;
viastacks.push_back( via );
fprintf( aFile, "PAD V%d.%d.%s ROUND %g\nCIRCLE 0 0 %g\n",
via->GetWidth(), via->GetDrillValue(),
fmt_mask( via->GetLayerSet() ).c_str(),
via->GetDrillValue() / SCALE_FACTOR,
via->GetWidth() / (SCALE_FACTOR * 2) );
}
// Emit component pads
D_PAD* old_pad = 0;
int pad_name_number = 0;
for( unsigned i = 0; i<pads.size(); ++i )
{
D_PAD* pad = pads[i];
pad->SetSubRatsnest( pad_name_number );
if( old_pad && 0==D_PAD::Compare( old_pad, pad ) )
continue; // already created
old_pad = pad;
pad_name_number++;
pad->SetSubRatsnest( pad_name_number );
fprintf( aFile, "PAD P%d", pad->GetSubRatsnest() );
padstacks.push_back( pad ); // Will have its own padstack later
int dx = pad->GetSize().x / 2;
int dy = pad->GetSize().y / 2;
switch( pad->GetShape() )
{
default:
case PAD_SHAPE_CIRCLE:
fprintf( aFile, " ROUND %g\n",
pad->GetDrillSize().x / SCALE_FACTOR );
/* Circle is center, radius */
fprintf( aFile, "CIRCLE %g %g %g\n",
pad->GetOffset().x / SCALE_FACTOR,
-pad->GetOffset().y / SCALE_FACTOR,
pad->GetSize().x / (SCALE_FACTOR * 2) );
break;
case PAD_SHAPE_RECT:
fprintf( aFile, " RECTANGULAR %g\n",
pad->GetDrillSize().x / SCALE_FACTOR );
// Rectangle is begin, size *not* begin, end!
fprintf( aFile, "RECTANGLE %g %g %g %g\n",
(-dx + pad->GetOffset().x ) / SCALE_FACTOR,
(-dy - pad->GetOffset().y ) / SCALE_FACTOR,
dx / (SCALE_FACTOR / 2), dy / (SCALE_FACTOR / 2) );
break;
//.........这里部分代码省略.........