本文整理汇总了C++中kigfx::GAL::GetWorldScale方法的典型用法代码示例。如果您正苦于以下问题:C++ GAL::GetWorldScale方法的具体用法?C++ GAL::GetWorldScale怎么用?C++ GAL::GetWorldScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kigfx::GAL
的用法示例。
在下文中一共展示了GAL::GetWorldScale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UseGalCanvas
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
{
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
// Display the same view after canvas switching
if( aEnable )
{
// Switch to GAL renderer from legacy
if( !m_galCanvasActive )
{
// Set up viewport
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
}
// Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
// Transfer EDA_DRAW_PANEL settings
GetGalCanvas()->GetViewControls()->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() );
GetGalCanvas()->GetViewControls()->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
GetGalCanvas()->GetViewControls()->EnableAutoPan( m_canvas->GetEnableAutoPan() );
}
else if( m_galCanvasActive )
{
// Switch to legacy renderer from GAL
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
// TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
VECTOR2D center = view->GetCenter();
AdjustScrollBars( wxPoint( center.x, center.y ) );
}
m_canvas->SetEvtHandlerEnabled( !aEnable );
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
// Switch panes
m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
m_auimgr.Update();
// Reset current tool on switch();
SetNoToolSelected();
m_galCanvasActive = aEnable;
}
示例2: drawTicksAlongLine
/**
* Draw labelled ticks on a line. Ticks are spaced according to a
* maximum density. Miror ticks are not labelled.
*
* @param aGal the GAL to draw on
* @param aOrigin start of line to draw ticks on
* @param aLine line vector
* @param aMinorTickLen length of minor ticks in IU
*/
void drawTicksAlongLine( KIGFX::GAL& aGal, const VECTOR2D& aOrigin,
const VECTOR2D& aLine, double aMinorTickLen )
{
VECTOR2D tickLine = aLine.Rotate( -M_PI_2 );
double tickSpace;
TICK_FORMAT tickF = getTickFormatForScale( aGal.GetWorldScale(), tickSpace );
// number of ticks in whole ruler
int numTicks = (int) std::ceil( aLine.EuclideanNorm() / tickSpace );
// work out which way up the tick labels go
double labelAngle = -tickLine.Angle();
if( aLine.Angle() > 0 )
{
aGal.SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
}
else
{
aGal.SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
labelAngle += M_PI;
}
// text and ticks are dimmed
aGal.SetStrokeColor( PreviewOverlayDefaultColor().WithAlpha( PreviewOverlayDeemphAlpha( true ) ) );
const auto labelOffset = tickLine.Resize( aMinorTickLen * ( majorTickLengthFactor + 1 ) );
for( int i = 0; i < numTicks; ++i )
{
const auto tickPos = aOrigin + aLine.Resize( tickSpace * i );
double length = aMinorTickLen;
bool drawLabel = false;
if( i % tickF.majorStep == 0)
{
drawLabel = true;
length *= majorTickLengthFactor;
}
else if( tickF.midStep && i % tickF.midStep == 0 )
{
drawLabel = true;
length *= midTickLengthFactor;
}
aGal.DrawLine( tickPos, tickPos + tickLine.Resize( length ) );
if( drawLabel )
{
wxString label = DimensionLabel( "", tickSpace * i, g_UserUnit );
// FIXME: spaces choke OpenGL lp:1668455
label.erase( std::remove( label.begin(), label.end(), ' ' ), label.end() );
aGal.BitmapText( label, tickPos + labelOffset, labelAngle );
}
}
}
示例3: ZoomPreset
int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
{
unsigned int idx = aEvent.Parameter<long>();
std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
m_frame->SetPresetZoom( idx );
if( idx == 0 ) // Zoom Auto
{
return ZoomFitScreen( aEvent );
}
else if( idx >= zoomList.size() )
{
assert( false );
return 0;
}
double selectedZoom = zoomList[idx];
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
view->SetScale( 1.0 / ( zoomFactor * selectedZoom ) );
return 0;
}
示例4: ZoomFitScreen
int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
BOARD* board = getModel<BOARD>();
board->ComputeBoundingBox();
BOX2I boardBBox = board->ViewBBox();
VECTOR2I screenSize = gal->GetScreenPixelSize();
if( boardBBox.GetSize().x == 0 || boardBBox.GetSize().y == 0 )
{
// Empty view
view->SetCenter( view->ToWorld( VECTOR2D( screenSize.x / 2, screenSize.y / 2 ) ) );
view->SetScale( 17.0 );
}
else
{
// Autozoom to board
double iuPerX = screenSize.x ? boardBBox.GetWidth() / screenSize.x : 1.0;
double iuPerY = screenSize.y ? boardBBox.GetHeight() / screenSize.y : 1.0;
double bestZoom = std::max( iuPerX, iuPerY );
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * bestZoom );
view->SetCenter( boardBBox.Centre() );
view->SetScale( zoom );
}
return 0;
}
示例5: UseGalCanvas
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
{
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
// Display the same view after canvas switching
if( aEnable )
{
BASE_SCREEN* screen = GetScreen();
// Switch to GAL rendering
if( !IsGalCanvasActive() )
{
// Set up viewport
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
}
// Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
}
else
{
// Switch to standard rendering
if( IsGalCanvasActive() )
{
// Change view settings only if GAL was active previously
double zoom = 1.0 / ( zoomFactor * view->GetScale() );
m_canvas->SetZoom( zoom );
VECTOR2D center = view->GetCenter();
RedrawScreen( wxPoint( center.x, center.y ), false );
}
}
m_canvas->SetEvtHandlerEnabled( !aEnable );
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
// Switch panes
m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
m_auimgr.Update();
// Reset current tool on switch();
SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
m_galCanvasActive = aEnable;
}
示例6: OnSelectZoom
void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
{
if( m_zoomSelectBox == NULL )
return; // Should not happen!
int id = m_zoomSelectBox->GetCurrentSelection();
if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
return;
if( id == 0 ) // Auto zoom (Fit in Page)
{
Zoom_Automatique( true );
}
else
{
id--;
double selectedZoom = GetScreen()->m_ZoomList[id];
if( GetScreen()->GetZoom() == selectedZoom )
return;
GetScreen()->SetZoom( selectedZoom );
if( IsGalCanvasActive() )
{
// Apply computed view settings to GAL
KIGFX::VIEW* view = GetGalCanvas()->GetView();
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * GetZoom() );
view->SetScale( zoom );
GetGalCanvas()->Refresh();
}
else
RedrawScreen( GetScrollCenterPosition(), false );
}
}
示例7: GetZoomLevelIndicator
const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
{
wxString Line;
double level = 0.0;
if( IsGalCanvasActive() )
{
KIGFX::GAL* gal = m_galCanvas->GetGAL();
KIGFX::VIEW* view = m_galCanvas->GetView();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
level = m_zoomLevelCoeff * zoomFactor * view->GetScale();
}
else if( BASE_SCREEN* screen = GetScreen() )
{
level = m_zoomLevelCoeff / (double) screen->GetZoom();
}
// returns a human readable value which can be displayed as zoom
// level indicator in dialogs.
Line.Printf( wxT( "Z %.2f" ), level );
return Line;
}