本文整理汇总了C++中EDA_RECT::Centre方法的典型用法代码示例。如果您正苦于以下问题:C++ EDA_RECT::Centre方法的具体用法?C++ EDA_RECT::Centre怎么用?C++ EDA_RECT::Centre使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EDA_RECT
的用法示例。
在下文中一共展示了EDA_RECT::Centre方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPaintShowPanel
/*
* Draw (on m_panelShowPin) the pin currently edited
* accroding to current settings in dialog
*/
void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelShowPin );
wxSize dc_size = dc.GetSize();
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Give a parent to m_dummyPin only from draw purpose.
// In fact m_dummyPin should not have a parent, but draw functions need a parent
// to know some options, about pin texts
LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent();
m_dummyPin->SetParent( libframe->GetComponent() );
// Calculate a suitable scale to fit the available draw area
EDA_RECT bBox = m_dummyPin->GetBoundingBox();
double xscale = (double) dc_size.x / bBox.GetWidth();
double yscale = (double) dc_size.y / bBox.GetHeight();
double scale = std::min( xscale, yscale );
// Give a 10% margin
scale *= 0.9;
dc.SetUserScale( scale, scale );
wxPoint offset = bBox.Centre();
NEGATE( offset.x );
NEGATE( offset.y );
GRResetPenAndBrush( &dc );
m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR, GR_COPY,
NULL, DefaultTransform );
m_dummyPin->SetParent(NULL);
event.Skip();
}
示例2: Plot
void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
const TRANSFORM& aTransform )
{
if( IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = m_Orient;
if( aTransform.y1 ) // Rotate component 90 deg.
{
if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT;
else
orient = TEXT_ORIENT_HORIZ;
}
EDA_RECT BoundaryBox = GetBoundingBox();
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() )
+ aOffset;
aPlotter->Text( textpos, GetDefaultColor(), m_Text, orient, m_Size,
hjustify, vjustify,
GetPenSize(), m_Italic, m_Bold );
}
示例3: estimateComponentInsertionPosition
wxPoint BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition()
{
wxPoint bestPosition;
if( !m_board->IsEmpty() )
{
// Position new components below any existing board features.
EDA_RECT bbox = m_board->ComputeBoundingBox( true );
if( bbox.GetWidth() || bbox.GetHeight() )
{
bestPosition.x = bbox.Centre().x;
bestPosition.y = bbox.GetBottom() + Millimeter2iu( 10 );
}
}
else
{
// Position new components in the center of the page when the board is empty.
wxSize pageSize = m_board->GetPageSettings().GetSizeIU();
bestPosition.x = pageSize.GetWidth() / 2;
bestPosition.y = pageSize.GetHeight() / 2;
}
return bestPosition;
}
示例4: Plot
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
const TRANSFORM& aTransform )
{
wxASSERT( plotter != NULL );
EDA_RECT bBox = GetBoundingBox();
// convert coordinates from draw Y axis to libedit Y axis
bBox.RevertYAxis();
wxPoint txtpos = bBox.Centre();
/* The text orientation may need to be flipped if the
* transformation matrix causes xy axes to be flipped. */
int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
// Get color
COLOR4D color;
if( plotter->GetColorMode() ) // Used normal color or selected color
color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor();
else
color = COLOR4D::BLACK;
plotter->Text( pos, color, GetShownText(),
t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT,
GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
GetPenSize(), IsItalic(), IsBold() );
}
示例5: renderPreview
// Render the preview in our m_componentView. If this gets more complicated, we should
// probably have a derived class from wxPanel; but this keeps things local.
void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
{
wxPaintDC dc( m_componentView );
EDA_COLOR_T bgcolor = m_parent->GetDrawBgColor();
dc.SetBackground( bgcolor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
dc.Clear();
if( aComponent == NULL )
return;
if( aUnit <= 0 )
aUnit = 1;
const wxSize dc_size = dc.GetSize();
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Find joint bounding box for everything we are about to draw.
EDA_RECT bBox = aComponent->GetBoundingBox( aUnit, m_deMorganConvert );
const double xscale = (double) dc_size.x / bBox.GetWidth();
const double yscale = (double) dc_size.y / bBox.GetHeight();
const double scale = std::min( xscale, yscale ) * 0.85;
dc.SetUserScale( scale, scale );
wxPoint offset = bBox.Centre();
NEGATE( offset.x );
NEGATE( offset.y );
aComponent->Draw( NULL, &dc, offset, aUnit, m_deMorganConvert, GR_COPY,
UNSPECIFIED_COLOR, DefaultTransform, true, true, false );
}
示例6: Plot
void SCH_FIELD::Plot( PLOTTER* aPlotter )
{
SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
wxT( "Cannot plot field with invalid parent." ) );
EDA_COLOR_T color = ReturnLayerColor( GetLayer() );
if( m_Attributs & TEXT_NO_VISIBLE )
return;
if( IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = m_Orient;
if( parent->GetTransform().y1 ) // Rotate component 90 deg.
{
if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT;
else
orient = TEXT_ORIENT_HORIZ;
}
/* Calculate the text justification, according to the component
* orientation/mirror
* this is a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation)
* - the DrawGraphicText function recalculate also H and H justifications
* according to the text orientation.
* - When a component is mirrored, the text is not mirrored and
* justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_RECT BoundaryBox = GetBoundingBox();
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre();
int thickness = GetPenSize();
if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) )
{
aPlotter->Text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
thickness, m_Italic, m_Bold );
}
else /* We plot the reference, for a multiple parts per package */
{
/* Adding A, B ... to the reference */
wxString Text = m_Text + LIB_COMPONENT::ReturnSubReference( parent->GetUnit() );
aPlotter->Text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
thickness, m_Italic, m_Bold );
}
}
示例7: BestZoom
double FOOTPRINT_EDIT_FRAME::BestZoom()
{
EDA_RECT ibbbox = GetBoardBoundingBox();
double sizeX = (double) ibbbox.GetWidth();
double sizeY = (double) ibbbox.GetHeight();
wxPoint centre = ibbbox.Centre();
// Reserve a 20% margin around "board" bounding box.
double margin_scale_factor = 1.2;
return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
}
示例8: Plot
void SCH_FIELD::Plot( PLOTTER* aPlotter )
{
SCH_COMPONENT* parent = ( SCH_COMPONENT* ) GetParent();
wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
wxT( "Cannot plot field with invalid parent." ) );
COLOR4D color = GetLayerColor( GetLayer() );
if( !IsVisible() )
return;
if( IsVoid() )
return;
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = GetTextAngle();
if( parent->GetTransform().y1 ) // Rotate component 90 deg.
{
if( orient == TEXT_ANGLE_HORIZ )
orient = TEXT_ANGLE_VERT;
else
orient = TEXT_ANGLE_HORIZ;
}
/* Calculate the text justification, according to the component
* orientation/mirror
* this is a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation)
* - the DrawGraphicText function recalculate also H and H justifications
* according to the text orientation.
* - When a component is mirrored, the text is not mirrored and
* justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_RECT BoundaryBox = GetBoundingBox();
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
wxPoint textpos = BoundaryBox.Centre();
int thickness = GetPenSize();
aPlotter->Text( textpos, color, GetFullyQualifiedText(), orient, GetTextSize(),
hjustify, vjustify,
thickness, IsItalic(), IsBold() );
}
示例9: Matches
bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation )
{
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) );
if( SCH_ITEM::Matches( m_Text, aSearchData ) )
{
EDA_RECT BoundaryBox = GetBoundingBox();
if( aFindLocation )
*aFindLocation = BoundaryBox.Centre();
return true;
}
return false;
}
示例10: BestZoom
double LIB_VIEW_FRAME::BestZoom()
{
/* Please, note: wxMSW before version 2.9 seems have
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
* edit file <wxWidgets>/src/msw/dc.cpp
* search for line static const int VIEWPORT_EXTENT = 1000;
* and replace by static const int VIEWPORT_EXTENT = 10000;
*/
LIB_COMPONENT* component = NULL;
double bestzoom = 16.0; // default value for bestzoom
CMP_LIBRARY* lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib )
component = lib->FindComponent( m_entryName );
if( component == NULL )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return bestzoom;
}
wxSize size = m_canvas->GetClientSize();
EDA_RECT BoundaryBox = component->GetBoundingBox( m_unit, m_convert );
// Reserve a 10% margin around component bounding box.
double margin_scale_factor = 0.8;
double zx =(double) BoundaryBox.GetWidth() /
( margin_scale_factor * (double)size.x );
double zy = (double) BoundaryBox.GetHeight() /
( margin_scale_factor * (double)size.y);
// Calculates the best zoom
bestzoom = std::max( zx, zy );
// keep it >= minimal existing zoom (can happen for very small components
// like small power symbols
if( bestzoom < GetScreen()->m_ZoomList[0] )
bestzoom = GetScreen()->m_ZoomList[0];
SetScrollCenterPosition( BoundaryBox.Centre() );
return bestzoom;
}
示例11: BestZoom
double PCB_BASE_FRAME::BestZoom()
{
if( m_Pcb == NULL )
return 1.0;
EDA_RECT ibbbox = GetBoardBoundingBox();
DSIZE clientz = m_canvas->GetClientSize();
DSIZE boardz( ibbbox.GetWidth(), ibbbox.GetHeight() );
double iu_per_du_X = clientz.x ? boardz.x / clientz.x : 1.0;
double iu_per_du_Y = clientz.y ? boardz.y / clientz.y : 1.0;
double bestzoom = std::max( iu_per_du_X, iu_per_du_Y );
GetScreen()->SetScrollCenterPosition( ibbbox.Centre() );
return bestzoom;
}
示例12: BestZoom
double GERBVIEW_FRAME::BestZoom()
{
GERBER_DRAW_ITEM* item = GetGerberLayout()->m_Drawings;
// gives a minimal value to zoom, if no item in list
if( item == NULL )
return ZOOM_FACTOR( 350.0 );
EDA_RECT bbox = GetGerberLayout()->ComputeBoundingBox();
wxSize size = m_canvas->GetClientSize();
double x = (double) bbox.GetWidth() / (double) size.x;
double y = (double) bbox.GetHeight() / (double) size.y;
SetScrollCenterPosition( bbox.Centre() );
double best_zoom = std::max( x, y );
return best_zoom;
}
示例13: BestZoom
double LIB_VIEW_FRAME::BestZoom()
{
LIB_PART* part = NULL;
double defaultLibraryZoom = 7.33;
if( m_libraryName.IsEmpty() || m_entryName.IsEmpty() )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return defaultLibraryZoom;
}
LIB_ALIAS* alias = nullptr;
try
{
alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
}
catch( ... )
{
}
if( alias )
part = alias->GetPart();
if( !part )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return defaultLibraryZoom;
}
EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
double sizeX = (double) boundingBox.GetWidth();
double sizeY = (double) boundingBox.GetHeight();
wxPoint centre = boundingBox.Centre();
// Reserve a 20% margin around component bounding box.
double margin_scale_factor = 1.2;
return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
}
示例14: BestZoom
double GERBVIEW_FRAME::BestZoom()
{
EDA_RECT bbox = GetGerberLayout()->ComputeBoundingBox();
// gives a size to bbox (current page size), if no item in list
if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
{
wxSize pagesize = GetPageSettings().GetSizeMils();
bbox.SetSize( wxSize( Mils2iu( pagesize.x ), Mils2iu( pagesize.y ) ) );
}
// Compute best zoom:
wxSize size = m_canvas->GetClientSize();
double x = (double) bbox.GetWidth() / (double) size.x;
double y = (double) bbox.GetHeight() / (double) size.y;
double best_zoom = std::max( x, y ) * 1.1;
SetScrollCenterPosition( bbox.Centre() );
return best_zoom;
}
示例15: BestZoom
double LIB_EDIT_FRAME::BestZoom()
{
LIB_PART* part = GetCurPart();
double defaultLibraryZoom = 7.33;
if( !part )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return defaultLibraryZoom;
}
EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
double sizeX = (double) boundingBox.GetWidth();
double sizeY = (double) boundingBox.GetHeight();
wxPoint centre = boundingBox.Centre();
// Reserve a 20% margin around component bounding box.
double margin_scale_factor = 1.2;
return bestZoom( sizeX, sizeY, margin_scale_factor, centre);
}