本文整理汇总了C++中EDA_RECT::Inflate方法的典型用法代码示例。如果您正苦于以下问题:C++ EDA_RECT::Inflate方法的具体用法?C++ EDA_RECT::Inflate怎么用?C++ EDA_RECT::Inflate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EDA_RECT
的用法示例。
在下文中一共展示了EDA_RECT::Inflate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HitTest
bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT box;
EDA_RECT arect = aRect;
arect.Inflate( aAccuracy );
box.SetOrigin( GetStart() );
box.Inflate( GetWidth() / 2 );
if( aContained )
return arect.Contains( box );
else
return arect.Intersects( box );
}
示例2: HitTest
bool DIMENSION::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
arect.Inflate( aAccuracy );
EDA_RECT rect = GetBoundingBox();
if( aAccuracy )
rect.Inflate( aAccuracy );
if( aContained )
return arect.Contains( rect );
return arect.Intersects( rect );
}
示例3: TransformBoundingBoxWithClearanceToPolygon
void EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(
SHAPE_POLY_SET* aCornerBuffer, int aClearanceValue ) const
{
// Oh dear. When in UTF-8 mode, wxString puts string iterators in a linked list, and
// that linked list is not thread-safe.
std::lock_guard<std::mutex> guard( m_mutex );
if( GetText().Length() == 0 )
return;
wxPoint corners[4]; // Buffer of polygon corners
EDA_RECT rect = GetTextBox( -1 );
rect.Inflate( aClearanceValue );
corners[0].x = rect.GetOrigin().x;
corners[0].y = rect.GetOrigin().y;
corners[1].y = corners[0].y;
corners[1].x = rect.GetRight();
corners[2].x = corners[1].x;
corners[2].y = rect.GetBottom();
corners[3].y = corners[2].y;
corners[3].x = corners[0].x;
aCornerBuffer->NewOutline();
for( int ii = 0; ii < 4; ii++ )
{
// Rotate polygon
RotatePoint( &corners[ii].x, &corners[ii].y, GetTextPos().x, GetTextPos().y, GetTextAngle() );
aCornerBuffer->Append( corners[ii].x, corners[ii].y );
}
}
示例4: GetBoundingBox
const EDA_RECT LIB_BEZIER::GetBoundingBox() const
{
EDA_RECT rect;
int xmin, xmax, ymin, ymax;
if( !GetCornerCount() )
return rect;
xmin = xmax = m_PolyPoints[0].x;
ymin = ymax = m_PolyPoints[0].y;
for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
{
xmin = std::min( xmin, m_PolyPoints[ii].x );
xmax = std::max( xmax, m_PolyPoints[ii].x );
ymin = std::min( ymin, m_PolyPoints[ii].y );
ymax = std::max( ymax, m_PolyPoints[ii].y );
}
rect.SetOrigin( xmin, ymin );
rect.SetEnd( xmax, ymax );
rect.Inflate( ( GetPenSize()+1 ) / 2 );
rect.RevertYAxis();
return rect;
}
示例5: TransformBoundingBoxWithClearanceToPolygon
/**
* Function TransformBoundingBoxWithClearanceToPolygon
* Convert the text bounding box to a rectangular polygon
* Used in filling zones calculations
* Circles and arcs are approximated by segments
* @param aCornerBuffer = a buffer to store the polygon
* @param aClearanceValue = the clearance around the text bounding box
*/
void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(
SHAPE_POLY_SET& aCornerBuffer,
int aClearanceValue ) const
{
if( GetText().Length() == 0 )
return;
wxPoint corners[4]; // Buffer of polygon corners
EDA_RECT rect = GetTextBox( -1 );
rect.Inflate( aClearanceValue );
corners[0].x = rect.GetOrigin().x;
corners[0].y = rect.GetOrigin().y;
corners[1].y = corners[0].y;
corners[1].x = rect.GetRight();
corners[2].x = corners[1].x;
corners[2].y = rect.GetBottom();
corners[3].y = corners[2].y;
corners[3].x = corners[0].x;
aCornerBuffer.NewOutline();
for( int ii = 0; ii < 4; ii++ )
{
// Rotate polygon
RotatePoint( &corners[ii].x, &corners[ii].y, m_Pos.x, m_Pos.y, m_Orient );
aCornerBuffer.Append( corners[ii].x, corners[ii].y );
}
}
示例6: TstModuleOnBoard
/* Test if the module can be placed on the board.
* Returns the value TstRectangle().
* Module is known by its bounding box
*/
int TstModuleOnBoard( BOARD* Pcb, MODULE* aModule, bool TstOtherSide )
{
int side = TOP;
int otherside = BOTTOM;
if( aModule->GetLayer() == B_Cu )
{
side = BOTTOM; otherside = TOP;
}
EDA_RECT fpBBox = aModule->GetFootprintRect();
fpBBox.Move( -g_Offset_Module );
int diag = TstRectangle( Pcb, fpBBox, side );
if( diag != FREE_CELL )
return diag;
if( TstOtherSide )
{
diag = TstRectangle( Pcb, fpBBox, otherside );
if( diag != FREE_CELL )
return diag;
}
int marge = ( RoutingMatrix.m_GridRouting * aModule->GetPadCount() ) / GAIN;
fpBBox.Inflate( marge );
return CalculateKeepOutArea( fpBBox, side );
}
示例7: genModuleOnRoutingMatrix
/* Place module on Routing matrix.
*/
void genModuleOnRoutingMatrix( MODULE* Module )
{
int ox, oy, fx, fy;
int layerMask;
D_PAD* Pad;
EDA_RECT fpBBox = Module->GetBoundingBox();
fpBBox.Inflate( RoutingMatrix.m_GridRouting / 2 );
ox = fpBBox.GetX();
fx = fpBBox.GetRight();
oy = fpBBox.GetY();
fy = fpBBox.GetBottom();
if( ox < RoutingMatrix.m_BrdBox.GetX() )
ox = RoutingMatrix.m_BrdBox.GetX();
if( ox > RoutingMatrix.m_BrdBox.GetRight() )
ox = RoutingMatrix.m_BrdBox.GetRight();
if( fx < RoutingMatrix.m_BrdBox.GetX() )
fx = RoutingMatrix.m_BrdBox.GetX();
if( fx > RoutingMatrix.m_BrdBox.GetRight() )
fx = RoutingMatrix.m_BrdBox.GetRight();
if( oy < RoutingMatrix.m_BrdBox.GetY() )
oy = RoutingMatrix.m_BrdBox.GetY();
if( oy > RoutingMatrix.m_BrdBox.GetBottom() )
oy = RoutingMatrix.m_BrdBox.GetBottom();
if( fy < RoutingMatrix.m_BrdBox.GetY() )
fy = RoutingMatrix.m_BrdBox.GetY();
if( fy > RoutingMatrix.m_BrdBox.GetBottom() )
fy = RoutingMatrix.m_BrdBox.GetBottom();
layerMask = 0;
if( Module->GetLayer() == LAYER_N_FRONT )
layerMask = LAYER_FRONT;
if( Module->GetLayer() == LAYER_N_BACK )
layerMask = LAYER_BACK;
TraceFilledRectangle( ox, oy, fx, fy, layerMask,
CELL_is_MODULE, WRITE_OR_CELL );
// Trace pads + clearance areas.
for( Pad = Module->Pads(); Pad != NULL; Pad = Pad->Next() )
{
int margin = (RoutingMatrix.m_GridRouting / 2) + Pad->GetClearance();
::PlacePad( Pad, CELL_is_MODULE, margin, WRITE_OR_CELL );
}
// Trace clearance.
int margin = ( RoutingMatrix.m_GridRouting * Module->GetPadCount() ) / GAIN;
CreateKeepOutRectangle( ox, oy, fx, fy, margin, KEEP_OUT_MARGIN, layerMask );
}
示例8: HitTest
bool SCH_SHEET_PIN::HitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_RECT rect = GetBoundingBox();
rect.Inflate( aAccuracy );
return rect.Contains( aPoint );
}
示例9: BuildBoardPolygonOutlines
/* This function is used to extract a board outlines (3D view, automatic zones build ...)
* Any closed outline inside the main outline is a hole
* All contours should be closed, i.e. valid closed polygon vertices
*/
bool BuildBoardPolygonOutlines( BOARD* aBoard, SHAPE_POLY_SET& aOutlines,
wxString* aErrorText, unsigned int aTolerance, wxPoint* aErrorLocation )
{
PCB_TYPE_COLLECTOR items;
// Get all the DRAWSEGMENTS and module graphics into 'items',
// then keep only those on layer == Edge_Cuts.
static const KICAD_T scan_graphics[] = { PCB_LINE_T, PCB_MODULE_EDGE_T, EOT };
items.Collect( aBoard, scan_graphics );
// Make a working copy of aSegList, because the list is modified during calculations
std::vector< DRAWSEGMENT* > segList;
for( int ii = 0; ii < items.GetCount(); ii++ )
{
if( items[ii]->GetLayer() == Edge_Cuts )
segList.push_back( static_cast< DRAWSEGMENT* >( items[ii] ) );
}
bool success = ConvertOutlineToPolygon( segList, aOutlines, aErrorText, aTolerance, aErrorLocation );
if( !success || !aOutlines.OutlineCount() )
{
// Creates a valid polygon outline is not possible.
// So uses the board edge cuts bounding box to create a
// rectangular outline
// When no edge cuts items, build a contour
// from global bounding box
EDA_RECT bbbox = aBoard->GetBoardEdgesBoundingBox();
// If null area, uses the global bounding box.
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
bbbox = aBoard->ComputeBoundingBox();
// Ensure non null area. If happen, gives a minimal size.
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
bbbox.Inflate( Millimeter2iu( 1.0 ) );
aOutlines.RemoveAllContours();
aOutlines.NewOutline();
wxPoint corner;
aOutlines.Append( bbbox.GetOrigin() );
corner.x = bbbox.GetOrigin().x;
corner.y = bbbox.GetEnd().y;
aOutlines.Append( corner );
aOutlines.Append( bbbox.GetEnd() );
corner.x = bbbox.GetEnd().x;
corner.y = bbbox.GetOrigin().y;
aOutlines.Append( corner );
}
return success;
}
示例10: GetBoundingBox
EDA_RECT LIB_RECTANGLE::GetBoundingBox() const
{
EDA_RECT rect;
rect.SetOrigin( m_Pos.x, m_Pos.y * -1 );
rect.SetEnd( m_End.x, m_End.y * -1 );
rect.Inflate( (GetPenSize() / 2) + 1 );
return rect;
}
示例11: HitTest
bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
arect.Inflate( aAccuracy );
CRect rect = m_Poly->GetBoundingBox();
EDA_RECT bbox;
bbox.SetOrigin( rect.left, rect.bottom );
bbox.SetEnd( rect.right, rect.top );
if( aContained )
return arect.Contains( bbox );
else // Test for intersection between aRect and the polygon
// For a polygon, using its bounding box has no sense here
{
// Fast test: if aRect is outside the polygon bounding box,
// rectangles cannot intersect
if( ! bbox.Intersects( arect ) )
return false;
// aRect is inside the polygon bounding box,
// and can intersect the polygon: use a fine test.
// aRect intersects the polygon if at least one aRect corner
// is inside the polygon
wxPoint corner = arect.GetOrigin();
if( HitTestInsideZone( corner ) )
return true;
corner.x = arect.GetEnd().x;
if( HitTestInsideZone( corner ) )
return true;
corner = arect.GetEnd();
if( HitTestInsideZone( corner ) )
return true;
corner.x = arect.GetOrigin().x;
if( HitTestInsideZone( corner ) )
return true;
// No corner inside arect, but outlines can intersect arect
// if one of outline corners is inside arect
int count = m_Poly->GetCornersCount();
for( int ii =0; ii < count; ii++ )
{
if( arect.Contains( m_Poly->GetPos( ii ) ) )
return true;
}
return false;
}
}
示例12: HitTest
bool MODULE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
arect.Inflate( aAccuracy );
if( aContained )
return arect.Contains( m_BoundaryBox );
else
return m_BoundaryBox.Intersects( arect );
}
示例13: TextHitTest
bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
{
EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
wxPoint location = aPoint;
rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient );
return rect.Contains( location );
}
示例14: HitTest
bool PCB_TARGET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
arect.Inflate( aAccuracy );
if( aContained )
return arect.Contains( GetBoundingBox() );
else
return GetBoundingBox().Intersects( arect );
}
示例15: FillNegativeKnockout
/** Prefill in black an area a little bigger than the board to prepare for the
* negative plot */
static void FillNegativeKnockout( PLOTTER *aPlotter, const EDA_RECT &aBbbox )
{
const int margin = 5 * IU_PER_MM; // Add a 5 mm margin around the board
aPlotter->SetNegative( true );
aPlotter->SetColor( WHITE ); // Which will be plotted as black
EDA_RECT area = aBbbox;
area.Inflate( margin );
aPlotter->Rect( area.GetOrigin(), area.GetEnd(), FILLED_SHAPE );
aPlotter->SetColor( BLACK );
}