本文整理汇总了C++中EDA_RECT::GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ EDA_RECT::GetOrigin方法的具体用法?C++ EDA_RECT::GetOrigin怎么用?C++ EDA_RECT::GetOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EDA_RECT
的用法示例。
在下文中一共展示了EDA_RECT::GetOrigin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveFootprintsInArea
void moveFootprintsInArea( CRectPlacement& aPlacementArea,
std::vector <MODULE*>& aModuleList,
EDA_RECT& aFreeArea,
bool aFindAreaOnly )
{
CSubRectArray vecSubRects;
fillRectList( vecSubRects, aModuleList );
spreadRectangles( aPlacementArea, vecSubRects,
aFreeArea.GetWidth(), aFreeArea.GetHeight() );
if( aFindAreaOnly )
return;
for( unsigned it = 0; it < vecSubRects.size(); ++it )
{
wxPoint pos( vecSubRects[it].x, vecSubRects[it].y );
pos.x *= scale;
pos.y *= scale;
MODULE * module = aModuleList[vecSubRects[it].n];
EDA_RECT fpBBox = module->GetFootprintRect();
wxPoint mod_pos = pos + ( module->GetPosition() - fpBBox.GetOrigin() )
+ aFreeArea.GetOrigin();
module->Move( mod_pos - module->GetPosition() );
}
}
示例2: 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;
}
示例3: 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;
}
}
示例4: drawGraphic
void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
wxPoint pos1;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
wxPoint* buffer = NULL;
if( aColor < 0 ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
}
else
{
color = aColor;
}
buffer = new wxPoint[ m_PolyPoints.size() ];
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
{
buffer[ii] = aTransform.TransformCoordinate( m_PolyPoints[ii] ) + aOffset;
}
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
fill = NO_FILL;
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 1, GetPenSize(),
color, color );
else
GRPoly( clipbox, aDC, m_PolyPoints.size(), buffer, 0, GetPenSize(),
color, color );
delete[] buffer;
/* Set to one (1) to draw bounding box around polyline to validate
* bounding box calculation. */
#if 0
EDA_RECT bBox = GetBoundingBox();
bBox.Inflate( m_Thickness + 1, m_Thickness + 1 );
GRRect( clipbox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
示例5: drawGraphic
void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
void* aData, const TRANSFORM& aTransform )
{
wxPoint pos1, pos2;
EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
if( aColor < 0 ) // Used normal color or selected color
{
if( IsSelected() )
color = GetItemSelectedColor();
}
else
{
color = aColor;
}
pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset;
pos2 = aTransform.TransformCoordinate( m_End ) + aOffset;
FILL_T fill = aData ? NO_FILL : m_Fill;
if( aColor >= 0 )
fill = NO_FILL;
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL;
if( fill == FILLED_WITH_BG_BODYCOLOR && !aData )
GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ),
GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( m_Fill == FILLED_SHAPE && !aData )
GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GetPenSize(), color, color );
else
GRRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color );
/* Set to one (1) to draw bounding box around rectangle to validate
* bounding box calculation. */
#if 0
EDA_RECT bBox = GetBoundingBox();
bBox.Inflate( m_Thickness + 1, m_Thickness + 1 );
GRRect( clipbox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
示例6: GetBoundingBox
EDA_RECT SCH_FIELD::GetBoundingBox() const
{
SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness;
// We must pass the effective text thickness to GetTextBox
// when calculating the bounding box
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
// Calculate the text bounding box:
EDA_RECT rect;
// set USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR to 0 to use
// a justification relative to the text itself
// i.e. justification relative to an horizontal text
// or to 1 to keep the initial behavior
#if (USE_TEXT_JUSTIFY_INITIAL_BEHAVIOR == 1 )
if( m_Orient == TEXT_ORIENT_VERT )
{
// For vertical texts, exchange the horizontal and the vertical justification
// The idea is to keep the justification always left or top for instance,
// no matter the text orientation
SCH_FIELD text( *this ); // Make a local copy to swap justifications
// because GetBoundingBox() is const
int tmp = (int)text.m_VJustify;
NEGATE( tmp );
text.m_VJustify = (EDA_TEXT_VJUSTIFY_T)text.m_HJustify;
text.m_HJustify = (EDA_TEXT_HJUSTIFY_T)tmp;
rect = text.GetTextBox( -1, linewidth );
}
else
#endif
rect = GetTextBox( -1, linewidth );
// Calculate the bounding box position relative to the component:
wxPoint origin = parentComponent->GetPosition();
wxPoint pos = m_Pos - origin;
wxPoint begin = rect.GetOrigin() - origin;
wxPoint end = rect.GetEnd() - origin;
RotatePoint( &begin, pos, m_Orient );
RotatePoint( &end, pos, m_Orient );
// Due to the Y axis direction, we must mirror the bounding box,
// relative to the text position:
begin.y -= pos.y;
end.y -= pos.y;
NEGATE( begin.y );
NEGATE( end.y );
begin.y += pos.y;
end.y += pos.y;
// Now, apply the component transform (mirror/rot)
begin = parentComponent->GetTransform().TransformCoordinate( begin );
end = parentComponent->GetTransform().TransformCoordinate( end );
rect.SetOrigin( begin);
rect.SetEnd( end);
rect.Move( origin );
rect.Normalize();
return rect;
}
示例7: 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 );
}
}
示例8: 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 );
}
}
示例9: GetMsgPanelInfo
void LIB_BEZIER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
{
wxString msg;
EDA_RECT bBox = GetBoundingBox();
LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
msg = MessageTextFromValue( aUnits, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}
示例10: GetMsgPanelInfo
void LIB_POLYLINE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
{
wxString msg;
EDA_RECT bBox = GetBoundingBox();
LIB_ITEM::GetMsgPanelInfo( aList );
msg = StringFromValue( g_UserUnit, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}
示例11: GetBoundingBox
const EDA_RECT SCH_TEXT::GetBoundingBox() const
{
// We must pass the effective text thickness to GetTextBox
// when calculating the bounding box
int linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
EDA_RECT rect = GetTextBox( -1, linewidth );
if( GetTextAngle() != 0 ) // Rotate rect
{
wxPoint pos = rect.GetOrigin();
wxPoint end = rect.GetEnd();
RotatePoint( &pos, GetTextPos(), GetTextAngle() );
RotatePoint( &end, GetTextPos(), GetTextAngle() );
rect.SetOrigin( pos );
rect.SetEnd( end );
}
rect.Normalize();
return rect;
}
示例12: EraseScreen
void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
{
GRSetDrawMode( DC, GR_COPY );
COLOR4D bgColor = GetParent()->GetDrawBgColor();
GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, bgColor, bgColor );
// Set to one (1) to draw bounding box validate bounding box calculation.
#if DEBUG_SHOW_CLIP_RECT
EDA_RECT bBox = m_ClipBox;
GRRect( NULL, DC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
示例13: 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 );
}
示例14: drawGraphic
void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform )
{
wxPoint text_pos;
int color;
int linewidth = GetPenSize();
if( m_Bold )
linewidth = GetPenSizeForBold( m_Size.x );
else
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
if( ( m_Attributs & TEXT_NO_VISIBLE ) && ( aColor < 0 ) )
{
color = GetInvisibleItemColor();
}
else if( IsSelected() && ( aColor < 0 ) )
{
color = GetItemSelectedColor();
}
else
{
color = aColor;
}
if( color < 0 )
color = GetDefaultColor();
text_pos = aTransform.TransformCoordinate( m_Pos ) + aOffset;
wxString text;
if( aData )
text = *(wxString*)aData;
else
text = m_Text;
GRSetDrawMode( aDC, aDrawMode );
EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text, m_Orient, m_Size,
m_HJustify, m_VJustify, linewidth, m_Italic, m_Bold );
/* Set to one (1) to draw bounding box around field text to validate
* bounding box calculation. */
#if 0
EDA_RECT bBox = GetBoundingBox();
EDA_RECT grBox;
grBox.SetOrigin( aTransform.TransformCoordinate( bBox.GetOrigin() ) );
grBox.SetEnd( aTransform.TransformCoordinate( bBox.GetEnd() ) );
grBox.Move( aOffset );
GRRect( clipbox, aDC, grBox, 0, LIGHTMAGENTA );
#endif
}
示例15: CreateSVGFile
// Actual SVG file export function.
bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName )
{
PCB_PLOT_PARAMS m_plotOpts;
m_plotOpts.SetPlotFrameRef( PrintPageRef() );
// Adding drill marks, for copper layers
if( (m_printMaskLayer & ALL_CU_LAYERS) )
m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE );
else
m_plotOpts.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
m_plotOpts.SetSkipPlotNPTH_Pads( false );
m_plotOpts.SetMirror( m_printMirror );
m_plotOpts.SetFormat( PLOT_FORMAT_SVG );
EDA_COLOR_T color = UNSPECIFIED_COLOR; // Used layer color to plot ref and value
m_plotOpts.SetReferenceColor( color );
m_plotOpts.SetValueColor( color );
PAGE_INFO pageInfo = m_board->GetPageSettings();
wxPoint axisorigin = m_board->GetAuxOrigin();
if( PageIsBoardBoundarySize() )
{
EDA_RECT bbox = m_board->ComputeBoundingBox();
PAGE_INFO currpageInfo = m_board->GetPageSettings();
currpageInfo.SetWidthMils( bbox.GetWidth() / IU_PER_MILS );
currpageInfo.SetHeightMils( bbox.GetHeight() / IU_PER_MILS );
m_board->SetPageSettings( currpageInfo );
m_plotOpts.SetUseAuxOrigin( true );
wxPoint origin = bbox.GetOrigin();
m_board->SetAuxOrigin( origin );
}
LOCALE_IO toggle;
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( m_board,
&m_plotOpts, aFullFileName,
wxEmptyString );
if( plotter )
{
plotter->SetColorMode( m_ModeColorOption->GetSelection() == 0 );
PlotStandardLayer( m_board, plotter, m_printMaskLayer, m_plotOpts );
plotter->EndPlot();
}
delete plotter;
m_board->SetAuxOrigin( axisorigin );
m_board->SetPageSettings( pageInfo );
return true;
}