本文整理汇总了C++中LIB_PART::GetBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ LIB_PART::GetBoundingBox方法的具体用法?C++ LIB_PART::GetBoundingBox怎么用?C++ LIB_PART::GetBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIB_PART
的用法示例。
在下文中一共展示了LIB_PART::GetBoundingBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BestZoom
double LIB_EDIT_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;
*/
int dx, dy;
LIB_PART* part = GetCurPart();
if( part )
{
EDA_RECT boundingBox = part->GetBoundingBox( m_unit, m_convert );
dx = boundingBox.GetWidth();
dy = boundingBox.GetHeight();
SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
else
{
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
dx = pageInfo.GetSizeIU().x;
dy = pageInfo.GetSizeIU().y;
SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
wxSize size = m_canvas->GetClientSize();
// Reserve a 10% margin around component bounding box.
double margin_scale_factor = 0.8;
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
double bestzoom = std::max( zx, zy );
// keep it >= minimal existing zoom (can happen for very small components
// for instance when starting a new component
if( bestzoom < GetScreen()->m_ZoomList[0] )
bestzoom = GetScreen()->m_ZoomList[0];
return bestzoom;
}
示例2: 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_PART* part = NULL;
double bestzoom = 16.0; // default value for bestzoom
PART_LIB* lib = Prj().SchLibs()->FindLibrary( m_libraryName );
if( lib )
part = lib->FindPart( m_entryName );
if( !part )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
return bestzoom;
}
wxSize size = m_canvas->GetClientSize();
EDA_RECT boundingBox = part->GetBoundingBox( m_unit, m_convert );
// Reserve a 10% margin around component bounding box.
double margin_scale_factor = 0.8;
double zx =(double) boundingBox.GetWidth() /
( margin_scale_factor * (double)size.x );
double zy = (double) boundingBox.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( boundingBox.Centre() );
return bestzoom;
}
示例3: OnPlotCurrentComponent
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
{
wxString fullFileName;
wxString file_ext;
wxString mask;
LIB_PART* part = GetCurPart();
if( !part )
{
wxMessageBox( _( "No component" ) );
return;
}
switch( event.GetId() )
{
case ID_LIBEDIT_GEN_PNG_FILE:
{
bool fmt_is_jpeg = false; // could be selectable later. so keep this option.
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( fullFileName.IsEmpty() )
return;
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
CreatePNGorJPEGFile( fullFileName, fmt_is_jpeg );
}
break;
case ID_LIBEDIT_GEN_SVG_FILE:
{
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( fullFileName.IsEmpty() )
return;
PAGE_INFO pageSave = GetScreen()->GetPageSettings();
PAGE_INFO pageTemp = pageSave;
wxSize componentSize = part->GetBoundingBox( m_unit, m_convert ).GetSize();
// Add a small margin to the plot bounding box
pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) );
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
GetScreen()->SetPageSettings( pageTemp );
SVG_PlotComponent( fullFileName );
GetScreen()->SetPageSettings( pageSave );
}
break;
}
}