本文整理汇总了C++中kigfx::VIEW::SetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ VIEW::SetCenter方法的具体用法?C++ VIEW::SetCenter怎么用?C++ VIEW::SetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kigfx::VIEW
的用法示例。
在下文中一共展示了VIEW::SetCenter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ZoomFitScreen
int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = getView();
EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
BOARD* board = getModel<BOARD>();
board->ComputeBoundingBox();
BOX2I boardBBox = board->ViewBBox();
VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
if( boardBBox.GetWidth() == 0 || boardBBox.GetHeight() == 0 )
{
// Empty view
view->SetScale( 17.0 ); // works fine for the standard worksheet frame
view->SetCenter( screenSize / 2.0 );
}
else
{
VECTOR2D vsize = boardBBox.GetSize();
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
fabs( vsize.y / screenSize.y ) );
view->SetScale( scale );
view->SetCenter( boardBBox.Centre() );
}
// Take scrollbars into account
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
return 0;
}
示例2: 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;
}
示例3: PanControl
int PCBNEW_CONTROL::PanControl( const TOOL_EVENT& aEvent )
{
long type = aEvent.Parameter<long>();
KIGFX::VIEW* view = getView();
GRID_HELPER gridHelper( m_frame );
VECTOR2D center = view->GetCenter();
VECTOR2I gridSize = gridHelper.GetGrid() * 10;
switch( type )
{
case COMMON_ACTIONS::CURSOR_UP:
center -= VECTOR2D( 0, gridSize.y );
break;
case COMMON_ACTIONS::CURSOR_DOWN:
center += VECTOR2D( 0, gridSize.y );
break;
case COMMON_ACTIONS::CURSOR_LEFT:
center -= VECTOR2D( gridSize.x, 0 );
break;
case COMMON_ACTIONS::CURSOR_RIGHT:
center += VECTOR2D( gridSize.x, 0 );
break;
default:
assert( false );
break;
}
view->SetCenter( center );
return 0;
}
示例4: ZoomCenter
int PCBNEW_CONTROL::ZoomCenter( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
view->SetCenter( getViewControls()->GetCursorPosition() );
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: 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;
}
示例7: CursorControl
// Cursor control
int PCBNEW_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
{
long type = aEvent.Parameter<long>();
bool fastMove = type & COMMON_ACTIONS::CURSOR_FAST_MOVE;
type &= ~COMMON_ACTIONS::CURSOR_FAST_MOVE;
GRID_HELPER gridHelper( m_frame );
VECTOR2D cursor = getViewControls()->GetCursorPosition();
VECTOR2I gridSize = gridHelper.GetGrid();
VECTOR2D newCursor = gridHelper.Align( cursor );
if( fastMove )
gridSize = gridSize * 10;
switch( type )
{
case COMMON_ACTIONS::CURSOR_UP:
newCursor -= VECTOR2D( 0, gridSize.y );
break;
case COMMON_ACTIONS::CURSOR_DOWN:
newCursor += VECTOR2D( 0, gridSize.y );
break;
case COMMON_ACTIONS::CURSOR_LEFT:
newCursor -= VECTOR2D( gridSize.x, 0 );
break;
case COMMON_ACTIONS::CURSOR_RIGHT:
newCursor += VECTOR2D( gridSize.x, 0 );
break;
case COMMON_ACTIONS::CURSOR_CLICK: // fall through
case COMMON_ACTIONS::CURSOR_DBL_CLICK:
{
TOOL_ACTIONS action = TA_NONE;
int modifiers = 0;
modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
if( type == COMMON_ACTIONS::CURSOR_CLICK )
action = TA_MOUSE_CLICK;
else if( type == COMMON_ACTIONS::CURSOR_DBL_CLICK )
action = TA_MOUSE_DBLCLICK;
else
assert( false );
TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
evt.SetMousePosition( getViewControls()->GetCursorPosition() );
m_toolMgr->ProcessEvent( evt );
return 0;
}
break;
}
// Handler cursor movement
KIGFX::VIEW* view = getView();
newCursor = view->ToScreen( newCursor );
newCursor.x = KiROUND( newCursor.x );
newCursor.y = KiROUND( newCursor.y );
// Pan the screen if required
const VECTOR2I& screenSize = view->GetGAL()->GetScreenPixelSize();
BOX2I screenBox( VECTOR2I( 0, 0 ), screenSize );
if( !screenBox.Contains( newCursor ) )
{
VECTOR2D delta( 0, 0 );
if( newCursor.x < screenBox.GetLeft() )
{
delta.x = newCursor.x - screenBox.GetLeft();
newCursor.x = screenBox.GetLeft();
}
else if( newCursor.x > screenBox.GetRight() )
{
delta.x = newCursor.x - screenBox.GetRight();
// -1 is to keep the cursor within the drawing area,
// so the cursor coordinates are still updated
newCursor.x = screenBox.GetRight() - 1;
}
if( newCursor.y < screenBox.GetTop() )
{
delta.y = newCursor.y - screenBox.GetTop();
newCursor.y = screenBox.GetTop();
}
else if( newCursor.y > screenBox.GetBottom() )
{
delta.y = newCursor.y - screenBox.GetBottom();
// -1 is to keep the cursor within the drawing area,
// so the cursor coordinates are still updated
newCursor.y = screenBox.GetBottom() - 1;
}
view->SetCenter( view->GetCenter() + view->ToWorld( delta, false ) );
//.........这里部分代码省略.........
示例8: GetFootprintEditorFrameName
//.........这里部分代码省略.........
SetBoard( new BOARD() );
// In modedit, the default net clearance is not known.
// (it depends on the actual board)
// So we do not show the default clearance, by setting it to 0
// The footprint or pad specific clearance will be shown
GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 );
// Don't show the default board solder mask clearance in the footprint editor. Only the
// footprint or pad clearance setting should be shown if it is not 0.
GetBoard()->GetDesignSettings().m_SolderMaskMargin = 0;
// restore the last footprint from the project, if any
restoreLastFootprint();
// Ensure all layers and items are visible:
// In footprint editor, some layers have no meaning or
// cannot be used, but we show all of them, at least to be able
// to edit a bad layer
GetBoard()->SetVisibleAlls();
// However the "no net" mark on pads is useless, because there is
// no net in footprint editor: make it non visible
GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true );
// LoadSettings() *after* creating m_LayersManager, because LoadSettings()
// initialize parameters in m_LayersManager
LoadSettings( config() );
GetGalDisplayOptions().m_axesEnabled = true;
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// In modedit, set the default paper size to A4:
// this should be OK for all footprint to plot/print
SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
initLibraryTree();
m_treePane = new FOOTPRINT_TREE_PANE( this );
// Create the manager and dispatcher & route draw panel events to the dispatcher
setupTools();
// ReCreateMenuBar(); // UseGalCanvas() will do this for us.
ReCreateHToolbar();
ReCreateVToolbar();
ReCreateOptToolbar();
m_Layers->ReFill();
m_Layers->ReFillRender();
GetScreen()->m_Active_Layer = F_SilkS;
m_Layers->SelectLayer( F_SilkS );
m_Layers->OnLayerSelected();
m_auimgr.SetManagedWindow( this );
m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
// Horizontal items; layers 4 - 6
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
// Vertical items; layers 1 - 3
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(1)
.Caption( _( "Libraries" ) ).MinSize( 250, 400 )
.BestSize( m_defaultLibWidth, -1 ) );
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
.Caption( _( "Layers Manager" ) ).PaneBorder( false )
.MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
// Set up viewport
KIGFX::VIEW* view = GetGalCanvas()->GetView();
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas();
m_auimgr.Update();
updateTitle();
Raise(); // On some window managers, this is needed
Show( true );
Zoom_Automatique( false );
}
示例9: wxT
//.........这里部分代码省略.........
m_propertiesFrameWidth = 200;
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
SetIcon( icon );
// Create GAL canvas
#ifdef __WXMAC__
// Cairo renderer doesn't handle Retina displays
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
#else
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
#endif
auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
GetGalDisplayOptions(), m_canvasType );
SetGalCanvas( drawPanel );
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
setupTools();
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
wxWindow* stsbar = GetStatusBar();
int dims[] = {
// balance of status bar on far left is set to a default or whatever is left over.
-1,
// When using GetTextSize() remember the width of '1' is not the same
// as the width of '0' unless the font is fixed width, and it usually won't be.
// zoom:
GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
// cursor coords
GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
// delta distances
GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
// Coord origin (use the bigger message)
GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
// units display, Inches is bigger than mm
GetTextSize( _( "Inches" ), stsbar ).x + 10
};
SetStatusWidths( arrayDim( dims ), dims );
m_auimgr.SetManagedWindow( this );
m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
m_propertiesPagelayout = new PROPERTIES_FRAME( this );
// Horizontal items; layers 4 - 6
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
// Vertical items; layers 1 - 3
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" ).Right().Layer(2)
.Caption( _( "Properties" ) ).MinSize( m_propertiesPagelayout->GetMinSize() )
.BestSize( m_propertiesFrameWidth, -1 ) );
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
// Set up viewport
KIGFX::VIEW* view = GetGalCanvas()->GetView();
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas();
m_auimgr.Update();
// Initialize the current page layout
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
#if 0 //start with empty layout
pglayout.AllowVoidList( true );
pglayout.ClearList();
#else // start with the default Kicad layout
pglayout.SetPageLayout();
#endif
OnNewPageLayout();
}