本文整理汇总了C++中PCB_BASE_FRAME::GetGalCanvas方法的典型用法代码示例。如果您正苦于以下问题:C++ PCB_BASE_FRAME::GetGalCanvas方法的具体用法?C++ PCB_BASE_FRAME::GetGalCanvas怎么用?C++ PCB_BASE_FRAME::GetGalCanvas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PCB_BASE_FRAME
的用法示例。
在下文中一共展示了PCB_BASE_FRAME::GetGalCanvas方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SwitchCursor
int PCBNEW_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
{
const unsigned int BIG_CURSOR = 8000;
const unsigned int SMALL_CURSOR = 80;
PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
KIGFX::GAL* gal = frame->GetGalCanvas()->GetGAL();
gal->SetCursorSize( frame->GetCursorShape() ? BIG_CURSOR : SMALL_CURSOR );
return 0;
}
示例2: GetFootprintEditorFrameName
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
{
m_showBorderAndTitleBlock = false; // true to show the frame references
m_showAxis = true; // true to show X and Y axis on screen
m_showGridAxis = true; // show the grid origin axis
m_hotkeysDescrList = g_Module_Editor_Hokeys_Descr;
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
SetIcon( icon );
// Show a title (frame title + footprint name):
updateTitle();
// Create GAL canvas
PCB_BASE_FRAME* parentFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
parentFrame->GetGalCanvas()->GetBackend() );
SetGalCanvas( drawPanel );
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);
// 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();
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true );
LoadSettings( config() );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
GetScreen()->SetCurItem( NULL );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, 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 );
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateAuxiliaryToolbar();
ReCreateVToolbar();
ReCreateOptToolbar();
if( m_canvas )
m_canvas->SetEnableBlockCommands( true );
m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane();
EDA_PANEINFO vert;
vert.VerticalToolbarPane();
EDA_PANEINFO mesg_pane;
mesg_pane.MessageToolbarPane();
// Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
// LAYER_WIDGET is floatable, but initially docked at far right
EDA_PANEINFO lyrs;
lyrs.LayersToolbarPane();
lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget
lyrs.BestSize( m_Layers->GetBestSize() );
lyrs.Caption( _( "Visibles" ) );
m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top(). Row( 0 ) );
m_auimgr.AddPane( m_auxiliaryToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
// The main right vertical toolbar
m_auimgr.AddPane( m_drawToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer(1) );
// Add the layer manager ( most right side of pcbframe )
m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 2 ) );
// Layers manager is visible
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( true );
// The left vertical toolbar (fast acces to display options)
//.........这里部分代码省略.........
示例3: CreateArray
//.........这里部分代码省略.........
// if renumbering, no need to increment
const bool increment = !array_opts->ShouldRenumberItems();
// Some items cannot be duplicated
// i.e. the ref and value fields of a footprint or zones
// therefore newItem can be null
if( m_editModules )
newItem = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else
{
#if 0
// @TODO: see if we allow zone duplication here
// Duplicate zones is especially tricky (overlaping zones must be merged)
// so zones are not duplicated
if( item->Type() == PCB_ZONE_AREA_T )
newItem = NULL;
else
#endif
newItem = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
}
if( newItem )
{
array_opts->TransformItem( ptN, newItem, rotPoint );
m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, newItem );
newItemList.PushItem( newItem );
if( newItem->Type() == PCB_MODULE_T)
{
static_cast<MODULE*>( newItem )->RunOnChildren( boost::bind( &KIGFX::VIEW::Add,
getView(), _1 ) );
}
editFrame->GetGalCanvas()->GetView()->Add( newItem );
getModel<BOARD>()->GetRatsnest()->Update( newItem );
}
}
// set the number if needed:
if( newItem && array_opts->ShouldRenumberItems() )
{
switch( newItem->Type() )
{
case PCB_PAD_T:
{
const wxString padName = array_opts->GetItemNumber( ptN );
static_cast<D_PAD*>( newItem )->SetPadName( padName );
originalItemsModified = true;
break;
}
case PCB_MODULE_T:
{
const wxString moduleName = array_opts->GetItemNumber( ptN );
MODULE* module = static_cast<MODULE*>( newItem );
module->SetReference( cachedString + moduleName );
originalItemsModified = true;
break;
}
case PCB_MODULE_TEXT_T:
case PCB_TEXT_T:
{
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( newItem );
if( text )
text->SetText( array_opts->InterpolateNumberIntoString( ptN, cachedString ) );
originalItemsModified = true;
break;
}
default:
// no renumbering of other items
break;
}
}
}
}
if( !m_editModules )
{
if( originalItemsModified )
{
// Update the appearance of the original items
selection.group->ItemsViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
// Add all items as a single undo point for PCB editors
// TODO: Can this be merged into the previous undo point (where
// we saved the original items)
editFrame->SaveCopyInUndoList( newItemList, UR_NEW );
}
}
getModel<BOARD>()->GetRatsnest()->Recalculate();
return 0;
}
示例4: Duplicate
int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
bool increment = aEvent.IsAction( &COMMON_ACTIONS::duplicateIncrement );
// first, check if we have a selection, or try to get one
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
// Be sure that there is at least one item that we can modify
if( !hoverSelection( selection ) )
return 0;
// we have a selection to work on now, so start the tool process
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
editFrame->OnModify();
// prevent other tools making undo points while the duplicate is going on
// so that if you cancel, you don't get a duplicate object hiding over
// the original
incUndoInhibit();
if( m_editModules )
editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT );
std::vector<BOARD_ITEM*> old_items;
for( int i = 0; i < selection.Size(); ++i )
{
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
if( item )
old_items.push_back( item );
}
for( unsigned i = 0; i < old_items.size(); ++i )
{
BOARD_ITEM* item = old_items[i];
// Unselect the item, so we won't pick it up again
// Do this first, so a single-item duplicate will correctly call
// SetCurItem and show the item properties
m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, item );
BOARD_ITEM* new_item = NULL;
if( m_editModules )
new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else
{
#if 0
// @TODO: see if we allow zone duplication here
// Duplicate zones is especially tricky (overlaping zones must be merged)
// so zones are not duplicated
if( item->Type() != PCB_ZONE_AREA_T )
#endif
new_item = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
}
if( new_item )
{
if( new_item->Type() == PCB_MODULE_T )
{
static_cast<MODULE*>( new_item )->RunOnChildren( boost::bind( &KIGFX::VIEW::Add,
getView(), _1 ) );
}
editFrame->GetGalCanvas()->GetView()->Add( new_item );
// Select the new item, so we can pick it up
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, new_item );
}
}
// record the new items as added
if( !m_editModules )
editFrame->SaveCopyInUndoList( selection.items, UR_NEW );
editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
(int) old_items.size() ) );
// pick up the selected item(s) and start moving
// this works well for "dropping" copies around
TOOL_EVENT evt = COMMON_ACTIONS::editActivate.MakeEvent();
Main( evt );
// and re-enable undos
decUndoInhibit();
return 0;
}
示例5: minsize
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) :
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
wxDefaultPosition, wxDefaultSize,
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
aParent ?
KICAD_DEFAULT_DRAWFRAME_STYLE | MODAL_MODE_EXTRASTYLE
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP
: KICAD_DEFAULT_DRAWFRAME_STYLE,
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
FOOTPRINT_VIEWER_FRAME_NAME_MODAL
: FOOTPRINT_VIEWER_FRAME_NAME )
{
wxASSERT( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ||
aFrameType == FRAME_PCB_MODULE_VIEWER );
if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL )
SetModal( true );
// Force the frame name used in config. the footprint viewer frame has a name
// depending on aFrameType (needed to identify the frame by wxWidgets),
// but only one configuration is preferable.
m_configFrameName = FOOTPRINT_VIEWER_FRAME_NAME;
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
SetIcon( icon );
m_hotkeysDescrList = g_Module_Viewer_Hokeys_Descr;
m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST,
wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST,
wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
SetBoard( new BOARD() );
// In viewer, 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);
// Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// Menu bar is not mandatory: uncomment/comment the next line
// to add/remove the menubar
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
ReCreateLibraryList();
UpdateTitle();
PCB_BASE_FRAME* parentFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
// Create GAL canvas
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
parentFrame->GetGalCanvas()->GetBackend() );
SetGalCanvas( drawPanel );
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
drawPanel->GetViewControls(), this );
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
m_toolManager->ResetTools( TOOL_BASE::RUN );
// If a footprint was previously loaded, reload it
if( getCurNickname().size() && getCurFootprintName().size() )
{
FPID id;
id.SetLibNickname( getCurNickname() );
id.SetFootprintName( getCurFootprintName() );
GetBoard()->Add( loadFootprint( id ) );
}
drawPanel->DisplayBoard( m_Pcb );
updateView();
m_auimgr.SetManagedWindow( this );
wxSize minsize(100,-1); // Min size of list boxes
// Main toolbar is initially docked at the top of the main window and dockable on any side.
// The close button is disable because the footprint viewer has no main menu to re-enable it.
//.........这里部分代码省略.........
示例6: Push
//.........这里部分代码省略.........
case PCB_LINE_T: // a segment not on copper layers
case PCB_TEXT_T: // a text on a layer
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like track segment on a copper layer)
case PCB_DIMENSION_T: // a dimension (graphic item)
case PCB_TARGET_T: // a target (graphic item)
case PCB_MARKER_T: // a marker used to show something
case PCB_ZONE_AREA_T:
itemsToDeselect.push_back( boardItem );
view->Remove( boardItem );
if( !( changeFlags & CHT_DONE ) )
board->Remove( boardItem );
break;
case PCB_MODULE_T:
{
itemsToDeselect.push_back( boardItem );
// There are no modules inside a module yet
wxASSERT( !m_editModules );
MODULE* module = static_cast<MODULE*>( boardItem );
view->Remove( module );
module->ClearFlags();
if( !( changeFlags & CHT_DONE ) )
board->Remove( module ); // handles connectivity
// Clear flags to indicate, that the ratsnest, list of nets & pads are not valid anymore
board->m_Status_Pcb = 0;
}
break;
default: // other types do not need to (or should not) be handled
wxASSERT( false );
break;
}
break;
}
case CHT_MODIFY:
{
if( !m_editModules && aCreateUndoEntry )
{
ITEM_PICKER itemWrapper( boardItem, UR_CHANGED );
wxASSERT( ent.m_copy );
itemWrapper.SetLink( ent.m_copy );
undoList.PushItem( itemWrapper );
}
if( ent.m_copy )
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
connectivity->Update( boardItem );
view->Update( boardItem );
// if no undo entry is needed, the copy would create a memory leak
if( !aCreateUndoEntry )
delete ent.m_copy;
break;
}
default:
wxASSERT( false );
break;
}
}
// Removing an item should trigger the unselect action
// but only after all items are removed otherwise we can get
// flickering depending on the system
if( itemsToDeselect.size() > 0 )
m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToDeselect );
if( !m_editModules && aCreateUndoEntry )
frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );
if( TOOL_MANAGER* toolMgr = frame->GetToolManager() )
toolMgr->PostEvent( { TC_MESSAGE, TA_MODEL_CHANGE, AS_GLOBAL } );
if ( !m_editModules )
{
auto panel = static_cast<PCB_DRAW_PANEL_GAL*>( frame->GetGalCanvas() );
connectivity->RecalculateRatsnest();
connectivity->ClearDynamicRatsnest();
panel->RedrawRatsnest();
}
if( aSetDirtyBit )
frame->OnModify();
frame->UpdateMsgPanel();
clear();
}