本文整理汇总了C++中BOARD_ITEM::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ BOARD_ITEM::Type方法的具体用法?C++ BOARD_ITEM::Type怎么用?C++ BOARD_ITEM::Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOARD_ITEM
的用法示例。
在下文中一共展示了BOARD_ITEM::Type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetOrientation
void MODULE::SetOrientation( double newangle )
{
double angleChange = newangle - m_Orient; // change in rotation
NORMALIZE_ANGLE_POS( newangle );
m_Orient = newangle;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->SetOrientation( pad->GetOrientation() + angleChange );
pad->SetDrawCoord();
}
// Update of the reference and value.
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
// Displace contours and text of the footprint.
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == PCB_MODULE_EDGE_T )
{
static_cast<EDGE_MODULE*>( item )->SetDrawCoord();
}
else if( item->Type() == PCB_MODULE_TEXT_T )
{
static_cast<TEXTE_MODULE*>( item )->SetDrawCoord();
}
}
CalculateBoundingBox();
}
示例2: 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;
}
示例3: Delete_Drawings_All_Layer
void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( LAYER_ID aLayer )
{
if( IsCopperLayer( aLayer ) )
{
DisplayError( this, _( "Copper layer global delete not allowed!" ) );
return;
}
wxString msg = wxString::Format(
_( "Delete everything on layer %s?" ),
GetChars( GetBoard()->GetLayerName( aLayer ) ) );
if( !IsOK( this, msg ) )
return;
PICKED_ITEMS_LIST pickList;
ITEM_PICKER picker( NULL, UR_DELETED );
BOARD_ITEM* PtNext;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext )
{
PtNext = item->Next();
switch( item->Type() )
{
case PCB_LINE_T:
case PCB_TEXT_T:
case PCB_DIMENSION_T:
case PCB_TARGET_T:
if( item->GetLayer() == aLayer )
{
item->UnLink();
picker.SetItem( item );
pickList.PushItem( picker );
}
break;
default:
{
wxString msg;
msg.Printf( wxT("Delete_Drawings_All_Layer() error: unknown type %d"),
item->Type() );
wxMessageBox( msg );
break;
}
}
}
if( pickList.GetCount() )
{
OnModify();
SaveCopyInUndoList(pickList, UR_DELETED);
}
}
示例4: addCornerCondition
bool POINT_EDITOR::addCornerCondition( const SELECTION& aSelection )
{
if( aSelection.Size() != 1 )
return false;
BOARD_ITEM* item = aSelection.Item<BOARD_ITEM>( 0 );
// Works only for zones and line segments
return item->Type() == PCB_ZONE_AREA_T ||
( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
}
示例5: CrossProbeSchToPcb
int PCB_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent )
{
BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
if( item )
{
m_probingSchToPcb = true;
getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
// If it is a pad and the net highlighting tool is enabled, highlight the net
if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
{
int net = static_cast<D_PAD*>( item )->GetNetCode();
m_toolMgr->RunAction( COMMON_ACTIONS::highlightNet, false, net );
}
else
// Otherwise simply select the corresponding item
{
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, item );
}
}
return 0;
}
示例6: GetTopLeftItem
EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
{
BOARD_ITEM* topLeftItem = nullptr;
BOARD_ITEM* currentItem;
wxPoint pnt;
// find the leftmost (smallest x coord) and highest (smallest y with the smallest x) item in the selection
for( auto item : m_items )
{
currentItem = static_cast<BOARD_ITEM*>( item );
pnt = currentItem->GetPosition();
if( ( currentItem->Type() != PCB_MODULE_T ) && onlyModules )
{
continue;
}
else
{
if( topLeftItem == nullptr )
{
topLeftItem = currentItem;
}
else if( ( pnt.x < topLeftItem->GetPosition().x ) ||
( ( topLeftItem->GetPosition().x == pnt.x ) &&
( pnt.y < topLeftItem->GetPosition().y ) ) )
{
topLeftItem = currentItem;
}
}
}
return static_cast<EDA_ITEM*>( topLeftItem );
}
示例7: AlignCenterY
int ALIGN_DISTRIBUTE_TOOL::AlignCenterY( const TOOL_EVENT& aEvent )
{
ALIGNMENT_RECTS itemsToAlign;
ALIGNMENT_RECTS locked_items;
if( !GetSelections( itemsToAlign, locked_items, []( const ALIGNMENT_RECT left, const ALIGNMENT_RECT right)
{ return ( left.second.GetCenter().y < right.second.GetCenter().y ); } ) )
return 0;
BOARD_COMMIT commit( m_frame );
commit.StageItems( m_selectionTool->GetSelection(), CHT_MODIFY );
auto targetY = selectTarget( itemsToAlign, locked_items, []( const ALIGNMENT_RECT& aVal )
{ return aVal.second.GetCenter().y; } );
// Move the selected items
for( auto& i : itemsToAlign )
{
int difference = targetY - i.second.GetCenter().y;
BOARD_ITEM* item = i.first;
// Don't move a pad by itself unless editing the footprint
if( item->Type() == PCB_PAD_T && m_frame->IsType( FRAME_PCB ) )
item = item->GetParent();
item->Move( wxPoint( 0, difference ) );
}
commit.Push( _( "Align to center" ) );
return 0;
}
示例8: OnHotkeyCopyItem
int PCB_EDIT_FRAME::OnHotkeyCopyItem()
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->GetFlags();
if( itemCurrentlyEdited )
return 0;
item = PcbGeneralLocateAndDisplay();
if( item == NULL )
return 0;
SetCurItem( item );
int eventId = 0;
switch( item->Type() )
{
case PCB_TEXT_T:
eventId = ID_POPUP_PCB_COPY_TEXTEPCB;
break;
default:
eventId = 0;
break;
}
return eventId;
}
示例9: OnHotkeyPlaceItem
bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
{
BOARD_ITEM* item = GetCurItem();
bool no_tool = GetToolId() == ID_NO_TOOL_SELECTED;
bool itemCurrentlyEdited = item && item->GetFlags();
m_canvas->SetAutoPanRequest( false );
if( itemCurrentlyEdited )
{
m_canvas->SetIgnoreMouseEvents( true );
m_canvas->CrossHairOff( aDC );
switch( item->Type() )
{
case PCB_TRACE_T:
case PCB_VIA_T:
if( item->IsDragging() )
PlaceDraggedOrMovedTrackSegment( static_cast<TRACK*>( item ), aDC );
break;
case PCB_TEXT_T:
Place_Texte_Pcb( static_cast<TEXTE_PCB*>( item ), aDC );
break;
case PCB_MODULE_TEXT_T:
PlaceTexteModule( static_cast<TEXTE_MODULE*>( item ), aDC );
break;
case PCB_PAD_T:
PlacePad( static_cast<D_PAD*>( item ), aDC );
break;
case PCB_MODULE_T:
PlaceModule( static_cast<MODULE*>( item ), aDC );
break;
case PCB_TARGET_T:
PlaceTarget( static_cast<PCB_TARGET*>( item ), aDC );
break;
case PCB_LINE_T:
if( no_tool ) // when no tools: existing item moving.
Place_DrawItem( static_cast<DRAWSEGMENT*>( item ), aDC );
break;
default:
break;
}
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->CrossHairOn( aDC );
return true;
}
return false;
}
示例10: PlotBoardGraphicItems
// plot items like text and graphics, but not tracks and module
void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
{
for( BOARD_ITEM* item = m_board->m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
{
case PCB_LINE_T:
PlotDrawSegment( (DRAWSEGMENT*) item);
break;
case PCB_TEXT_T:
PlotTextePcb( (TEXTE_PCB*) item );
break;
case PCB_DIMENSION_T:
PlotDimension( (DIMENSION*) item );
break;
case PCB_TARGET_T:
PlotPcbTarget( (PCB_TARGET*) item );
break;
case PCB_MARKER_T:
default:
break;
}
}
}
示例11: OnHotkeyEditItem
bool FOOTPRINT_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->GetFlags();
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
if( itemCurrentlyEdited || blockActive )
return false;
item = ModeditLocateAndDisplay();
if( item == NULL )
return false;
SetCurItem( item );
int evt_type = 0; // Used to post a wxCommandEvent on demand
switch( item->Type() )
{
case PCB_MODULE_T:
if( aIdCommand == HK_EDIT_ITEM )
evt_type = ID_POPUP_PCB_EDIT_MODULE_PRMS;
break;
case PCB_PAD_T:
if( aIdCommand == HK_EDIT_ITEM )
evt_type = ID_POPUP_PCB_EDIT_PAD;
break;
case PCB_MODULE_TEXT_T:
if( aIdCommand == HK_EDIT_ITEM )
evt_type = ID_POPUP_PCB_EDIT_TEXTMODULE;
break;
case PCB_MODULE_EDGE_T:
if( aIdCommand == HK_EDIT_ITEM )
evt_type = ID_POPUP_MODEDIT_EDIT_BODY_ITEM;
break;
default:
break;
}
if( evt_type != 0 )
{
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
evt.SetEventObject( this );
evt.SetId( evt_type );
wxPostEvent( this, evt );
return true;
}
return false;
}
示例12: Block_Flip
void PCB_EDIT_FRAME::Block_Flip()
{
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
wxPoint memo;
wxPoint center; // Position of the axis for inversion of all elements
OnModify();
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
itemsList->m_Status = UR_FLIPPED;
memo = GetCrossHairPosition();
center = GetScreen()->m_BlockLocate.Centre();
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
wxASSERT( item );
itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
item->Flip( center );
switch( item->Type() )
{
case PCB_MODULE_T:
item->ClearFlags();
m_Pcb->m_Status_Pcb = 0;
break;
// Move and rotate the track segments
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)
m_Pcb->m_Status_Pcb = 0;
break;
case PCB_ZONE_AREA_T:
case PCB_LINE_T:
case PCB_TEXT_T:
case PCB_TARGET_T:
case PCB_DIMENSION_T:
break;
// This item is not put in undo list
case PCB_ZONE_T: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii );
ii--;
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
break;
}
}
SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
Compile_Ratsnest( NULL, true );
m_canvas->Refresh( true );
}
示例13: Block_Delete
void PCB_EDIT_FRAME::Block_Delete()
{
OnModify();
SetCurItem( NULL );
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
itemsList->m_Status = UR_DELETED;
// unlink items and clear flags
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
itemsList->SetPickedItemStatus( UR_DELETED, ii );
GetBoard()->GetConnectivity()->Remove( item );
switch( item->Type() )
{
case PCB_MODULE_T:
{
MODULE* module = (MODULE*) item;
module->ClearFlags();
module->UnLink();
m_Pcb->m_Status_Pcb = 0;
}
break;
case PCB_ZONE_AREA_T: // a zone area
m_Pcb->Remove( item );
break;
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)
item->UnLink();
break;
// These items are deleted, but not put in undo list
case PCB_MARKER_T: // a marker used to show something
case PCB_ZONE_T: // SEG_ZONE items are now deprecated
item->UnLink();
itemsList->RemovePicker( ii );
ii--;
item->DeleteStructure();
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Delete( ) error: unexpected type" ) );
break;
}
}
SaveCopyInUndoList( *itemsList, UR_DELETED );
Compile_Ratsnest( NULL, true );
m_canvas->Refresh( true );
}
示例14: processChanges
void EDIT_TOOL::processChanges( const PICKED_ITEMS_LIST* aList )
{
KIGFX::VIEW* view = getView();
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
for( unsigned int i = 0; i < aList->GetCount(); ++i )
{
UNDO_REDO_T operation = aList->GetPickedItemStatus( i );
BOARD_ITEM* updItem = static_cast<BOARD_ITEM*>( aList->GetPickedItem( i ) );
switch( operation )
{
case UR_CHANGED:
ratsnest->Update( updItem );
// fall through
case UR_MODEDIT:
updItem->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
break;
case UR_DELETED:
if( updItem->Type() == PCB_MODULE_T )
static_cast<MODULE*>( updItem )->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove,
view, _1 ) );
view->Remove( updItem );
//ratsnest->Remove( updItem ); // this is done in BOARD::Remove
break;
case UR_NEW:
if( updItem->Type() == PCB_MODULE_T )
static_cast<MODULE*>( updItem )->RunOnChildren( boost::bind( &KIGFX::VIEW::Add,
view, _1 ) );
view->Add( updItem );
//ratsnest->Add( updItem ); // this is done in BOARD::Add
break;
default:
assert( false ); // Not handled
break;
}
}
}
示例15: Draw
void MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
const wxPoint& aOffset )
{
if( (m_Flags & DO_NOT_DRAW) || (IsMoving()) )
return;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
if( pad->IsMoving() )
continue;
pad->Draw( aPanel, aDC, aDrawMode, aOffset );
}
BOARD* brd = GetBoard();
// Draws footprint anchor
DrawAncre( aPanel, aDC, aOffset, DIM_ANCRE_MODULE, aDrawMode );
// Draw graphic items
if( brd->IsElementVisible( MOD_REFERENCES_VISIBLE ) )
{
if( !(m_Reference->IsMoving()) )
m_Reference->Draw( aPanel, aDC, aDrawMode, aOffset );
}
if( brd->IsElementVisible( MOD_VALUES_VISIBLE ) )
{
if( !(m_Value->IsMoving()) )
m_Value->Draw( aPanel, aDC, aDrawMode, aOffset );
}
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->IsMoving() )
continue;
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
case PCB_MODULE_EDGE_T:
item->Draw( aPanel, aDC, aDrawMode, aOffset );
break;
default:
break;
}
}
// Enable these line to draw m_BoundaryBox (debug tests purposes only)
#if 0
GRRect( aPanel->GetClipBox(), aDC, m_BoundaryBox, 0, BROWN );
#endif
}