本文整理汇总了C++中kigfx::VIEW类的典型用法代码示例。如果您正苦于以下问题:C++ VIEW类的具体用法?C++ VIEW怎么用?C++ VIEW使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VIEW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例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: Process_Special_Functions
/* Handles the selection of tools, menu, and popup menu commands.
*/
void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
switch( event.GetId() )
{
case wxID_PREFERENCES:
ShowPreferences( PlEditorHotkeysDescr, PlEditorHotkeysDescr, wxT( "pl_editor" ) );
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
DisplayHotkeyList( this, PlEditorHotkeysDescr );
break;
case ID_SELECT_PAGE_NUMBER:
{
KIGFX::VIEW* view = GetGalCanvas()->GetView();
view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 );
view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 );
m_canvas->Refresh();
}
break;
default:
wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
break;
}
}
示例5: TransferDataFromWindow
/*
* Update variables with new options
*/
bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow()
{
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_frame->GetDisplayOptions();
displ_opts->m_ShowTrackClearanceMode = UTIL::GetValFromConfig(
traceClearanceSelectMap, m_OptDisplayTracksClearance->GetSelection() );
displ_opts->m_DisplayPadIsol = m_OptDisplayPadClearence->GetValue();
displ_opts->m_DisplayPadNum = m_OptDisplayPadNumber->GetValue();
m_frame->SetElementVisibility( LAYER_NO_CONNECTS, m_OptDisplayPadNoConn->GetValue() );
displ_opts->m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
displ_opts->m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
m_galOptsPanel->TransferDataFromWindow();
// Apply changes to the GAL
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() );
view->RecacheAllItems();
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
m_frame->GetCanvas()->Refresh();
return true;
}
示例6: ZoomCenter
int PCBNEW_CONTROL::ZoomCenter( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
view->SetCenter( getViewControls()->GetCursorPosition() );
return 0;
}
示例7: InvokeDXFDialogBoardImport
bool InvokeDXFDialogBoardImport( PCB_BASE_FRAME* aCaller )
{
DIALOG_DXF_IMPORT dlg( aCaller );
bool success = ( dlg.ShowModal() == wxID_OK );
if( success )
{
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
PICKED_ITEMS_LIST picklist;
BOARD* board = aCaller->GetBoard();
KIGFX::VIEW* view = aCaller->GetGalCanvas()->GetView();
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
{
BOARD_ITEM* item = *it;
board->Add( item );
ITEM_PICKER itemWrapper( item, UR_NEW );
picklist.PushItem( itemWrapper );
if( aCaller->IsGalCanvasActive() )
view->Add( item );
}
aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
aCaller->OnModify();
}
return success;
}
示例8: OnRenderColorChange
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
{
wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );
myframe->Settings().Colors().SetItemColor( static_cast<GAL_LAYER_ID>( aId ), aColor );
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas && myframe->IsGalCanvasActive() )
{
if( aId == LAYER_GRID )
galCanvas->GetGAL()->SetGridColor( aColor );
KIGFX::VIEW* view = galCanvas->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( &myframe->Settings().Colors() );
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); // useful to update rastnest
view->UpdateLayerColor( aId );
// plated-through-holes don't have their own color; they use the background color
if( aId == LAYER_PCB_BACKGROUND )
view->UpdateLayerColor( LAYER_PADS_PLATEDHOLES );
galCanvas->ForceRefresh();
}
myframe->ReCreateHToolbar();
myframe->GetCanvas()->Refresh();
}
示例9: OnLayerColorChange
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
{
// Avoid setting the alpha channel, when we are in legacy mode,
// because in legacy mode the alpha channel is not used, but changing it
// destroys the GAL color setup
if( !myframe->IsGalCanvasActive() )
{
COLOR4D oldColor = myframe->Settings().Colors().GetLayerColor( aLayer );
aColor.a = oldColor.a;
}
myframe->Settings().Colors().SetLayerColor( aLayer, aColor );
if( myframe->IsGalCanvasActive() )
{
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( &myframe->Settings().Colors() );
view->UpdateLayerColor( aLayer );
view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
}
myframe->ReCreateHToolbar();
myframe->GetCanvas()->Refresh();
if( aLayer == LAYER_PCB_BACKGROUND )
myframe->SetDrawBgColor( aColor );
}
示例10: InvokeDXFDialogModuleImport
bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
{
wxASSERT( aModule );
DIALOG_DXF_IMPORT dlg( aCaller );
bool success = ( dlg.ShowModal() == wxID_OK );
if( success )
{
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
KIGFX::VIEW* view = aCaller->GetGalCanvas()->GetView();
aCaller->SaveCopyInUndoList( aModule, UR_MODEDIT );
aCaller->OnModify();
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
{
BOARD_ITEM* item = *it;
BOARD_ITEM* converted = NULL;
// Modules use different types for the same things,
// so we need to convert imported items to appropriate classes.
switch( item->Type() )
{
case PCB_LINE_T:
{
converted = new EDGE_MODULE( aModule );
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
aModule->Add( converted );
static_cast<EDGE_MODULE*>( converted )->SetLocalCoord();
delete item;
break;
}
case PCB_TEXT_T:
{
converted = new TEXTE_MODULE( aModule );
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
aModule->Add( converted );
static_cast<TEXTE_MODULE*>( converted )->SetLocalCoord();
delete item;
break;
}
default:
wxLogDebug( wxT( "type %d currently not handled" ), item->Type() );
break;
}
if( aCaller->IsGalCanvasActive() && converted )
view->Add( converted );
}
}
return success;
}
示例11: 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;
}
示例12: OnLayerColorChange
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetLayerColor( ToLAYER_ID( aLayer ), aColor );
if( myframe->IsGalCanvasActive() )
{
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->GetBoard()->GetColorsSettings() );
view->UpdateLayerColor( aLayer );
}
myframe->GetCanvas()->Refresh();
}
示例13: 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;
}
示例14: ZoomInOutCenter
int PCBNEW_CONTROL::ZoomInOutCenter( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = getView();
double zoomScale = 1.0;
if( aEvent.IsAction( &COMMON_ACTIONS::zoomInCenter ) )
zoomScale = 1.3;
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOutCenter ) )
zoomScale = 0.7;
view->SetScale( view->GetScale() * zoomScale );
return 0;
}
示例15: ZoomInOut
int PCBNEW_CONTROL::ZoomInOut( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
double zoomScale = 1.0;
if( aEvent.IsAction( &COMMON_ACTIONS::zoomIn ) )
zoomScale = 1.3;
else if( aEvent.IsAction( &COMMON_ACTIONS::zoomOut ) )
zoomScale = 0.7;
view->SetScale( view->GetScale() * zoomScale, getViewControls()->GetCursorPosition() );
return 0;
}