本文整理汇总了C++中DLIST类的典型用法代码示例。如果您正苦于以下问题:C++ DLIST类的具体用法?C++ DLIST怎么用?C++ DLIST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DLIST类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveBacktracks
/**
* In a contiguous list of wires, remove wires that backtrack over the previous
* wire. Example:
*
* Wire is added:
* ---------------------------------------->
*
* A second wire backtracks over it:
* -------------------<====================>
*
* RemoveBacktracks is called:
* ------------------->
*/
static void RemoveBacktracks( DLIST<SCH_ITEM>& aWires )
{
SCH_LINE* last_line = NULL;
EDA_ITEM* first = aWires.GetFirst();
for( EDA_ITEM* p = first; p; )
{
SCH_LINE *line = dynamic_cast<SCH_LINE*>( p );
if( !line )
{
wxFAIL_MSG( "RemoveBacktracks() requires SCH_LINE items" );
break;
}
p = line->Next();
if( last_line )
{
wxASSERT_MSG( last_line->GetEndPoint() == line->GetStartPoint(),
"RemoveBacktracks() requires contiguous lines" );
if( IsPointOnSegment( last_line->GetStartPoint(), line->GetStartPoint(),
line->GetEndPoint() ) )
{
last_line->SetEndPoint( line->GetEndPoint() );
delete s_wires.Remove( line );
}
else
last_line = line;
}
else
last_line = line;
}
}
示例2: GetList
void BOARD_ITEM::UnLink()
{
DLIST<BOARD_ITEM>* list = (DLIST<BOARD_ITEM>*) GetList();
wxASSERT( list );
if( list )
list->Remove( this );
}
示例3: ExtractWires
void SCH_SCREEN::ExtractWires( DLIST< SCH_ITEM >& aList, bool aCreateCopy )
{
SCH_ITEM* item;
SCH_ITEM* next_item;
for( item = m_drawList.begin(); item; item = next_item )
{
next_item = item->Next();
switch( item->Type() )
{
case SCH_JUNCTION_T:
case SCH_LINE_T:
m_drawList.Remove( item );
aList.Append( item );
if( aCreateCopy )
m_drawList.Insert( (SCH_ITEM*) item->Clone(), next_item );
break;
default:
break;
}
}
}
示例4: RemoveBacktracks
/**
* In a contiguous list of wires, remove wires that backtrack over the previous
* wire. Example:
*
* Wire is added:
* ---------------------------------------->
*
* A second wire backtracks over it:
* -------------------<====================>
*
* RemoveBacktracks is called:
* ------------------->
*/
static void RemoveBacktracks( DLIST<SCH_ITEM>& aWires )
{
EDA_ITEM* first = aWires.GetFirst();
std::vector<SCH_LINE*> last_lines;
for( EDA_ITEM* p = first; p; )
{
SCH_LINE *line = static_cast<SCH_LINE*>( p );
p = line->Next();
if( !last_lines.empty() )
{
SCH_LINE* last_line = last_lines[last_lines.size() - 1];
bool contiguous = ( last_line->GetEndPoint() == line->GetStartPoint() );
bool backtracks = IsPointOnSegment( last_line->GetStartPoint(),
last_line->GetEndPoint(), line->GetEndPoint() );
bool total_backtrack = ( last_line->GetStartPoint() == line->GetEndPoint() );
if( contiguous && backtracks )
{
if( total_backtrack )
{
delete s_wires.Remove( last_line );
delete s_wires.Remove( line );
last_lines.pop_back();
}
else
{
last_line->SetEndPoint( line->GetEndPoint() );
delete s_wires.Remove( line );
}
}
else
{
last_lines.push_back( line );
}
}
else
{
last_lines.push_back( line );
}
}
}
示例5: GetScreen
void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
{
SCH_SCREEN* screen = GetScreen();
SCH_LINE* segment = (SCH_LINE*) screen->GetCurItem();
if( segment == NULL || segment->Type() != SCH_LINE_T || !segment->IsNew() )
return;
// Delete zero length segments and clear item flags.
SCH_ITEM* item = s_wires.begin();
while( item )
{
item->ClearFlags();
wxCHECK_RET( item->Type() == SCH_LINE_T, wxT( "Unexpected object type in wire list." ) );
segment = (SCH_LINE*) item;
item = item->Next();
if( segment->IsNull() )
delete s_wires.Remove( segment );
}
if( s_wires.GetCount() == 0 )
return;
// Get the last non-null wire (this is the last created segment).
SetRepeatItem( segment = (SCH_LINE*) s_wires.GetLast() );
screen->SetCurItem( NULL );
m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false );
// store the terminal point of this last segment: a junction could be needed
// (the last wire could be merged/deleted/modified, and lost)
wxPoint endpoint = segment->GetEndPoint();
// store the starting point of this first segment: a junction could be needed
SCH_LINE* firstsegment = (SCH_LINE*) s_wires.GetFirst();
wxPoint startPoint = firstsegment->GetStartPoint();
// Save the old wires for the undo command
DLIST< SCH_ITEM > oldWires; // stores here the old wires
GetScreen()->ExtractWires( oldWires, true ); // Save them in oldWires list
// Put the snap shot of the previous wire, buses, and junctions in the undo/redo list.
PICKED_ITEMS_LIST oldItems;
oldItems.m_Status = UR_WIRE_IMAGE;
while( oldWires.GetCount() != 0 )
{
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
oldItems.PushItem( picker );
}
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
// Remove segments backtracking over others
RemoveBacktracks( s_wires );
// Add the new wires
screen->Append( s_wires );
// Correct and remove segments that need to be merged.
screen->SchematicCleanUp();
// A junction could be needed to connect the end point of the last created segment.
if( screen->IsJunctionNeeded( endpoint ) )
screen->Append( AddJunction( DC, endpoint ) );
// A junction could be needed to connect the start point of the set of new created wires
if( screen->IsJunctionNeeded( startPoint ) )
screen->Append( AddJunction( DC, startPoint ) );
m_canvas->Refresh();
OnModify();
}
示例6: PutDataInPreviousState
void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
{
SCH_ITEM* item;
SCH_ITEM* alt_item;
// Exchange the current wires, buses, and junctions with the copy save by the last edit.
if( aList->m_Status == UR_WIRE_IMAGE )
{
DLIST< SCH_ITEM > oldWires;
// Prevent items from being deleted when the DLIST goes out of scope.
oldWires.SetOwnership( false );
// Remove all of the wires, buses, and junctions from the current screen.
GetScreen()->ExtractWires( oldWires, false );
// Copy the saved wires, buses, and junctions to the current screen.
for( unsigned int i = 0; i < aList->GetCount(); i++ )
GetScreen()->Append( (SCH_ITEM*) aList->GetPickedItem( i ) );
aList->ClearItemsList();
// Copy the previous wires, buses, and junctions to the picked item list for the
// redo operation.
while( oldWires.GetCount() != 0 )
{
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
aList->PushItem( picker );
}
return;
}
// Undo in the reverse order of list creation: (this can allow stacked changes like the
// same item can be changes and deleted in the same complex command.
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{
item = (SCH_ITEM*) aList->GetPickedItem( ii );
wxASSERT( item );
item->ClearFlags();
SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( ii );
switch( aList->GetPickedItemStatus( ii ) )
{
case UR_CHANGED: /* Exchange old and new data for each item */
item->SwapData( image );
break;
case UR_NEW: /* new items are deleted */
aList->SetPickedItemStatus( UR_DELETED, ii );
GetScreen()->Remove( item );
break;
case UR_DELETED: /* deleted items are put in the draw item list, as new items */
aList->SetPickedItemStatus( UR_NEW, ii );
GetScreen()->Append( item );
break;
case UR_MOVED:
item->ClearFlags();
item->SetFlags( aList->GetPickerFlags( ii ) );
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
item->ClearFlags();
break;
case UR_MIRRORED_Y:
item->MirrorY( aList->m_TransformPoint.x );
break;
case UR_MIRRORED_X:
item->MirrorX( aList->m_TransformPoint.y );
break;
case UR_ROTATED:
// To undo a rotate 90 deg transform we must rotate 270 deg to undo
// and 90 deg to redo:
item->Rotate( aList->m_TransformPoint );
if( aRedoCommand )
break; // A only one rotate transform is OK
// Make 3 rotate 90 deg transforms is this is actually an undo command
item->Rotate( aList->m_TransformPoint );
item->Rotate( aList->m_TransformPoint );
break;
case UR_EXCHANGE_T:
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii );
alt_item->SetNext( NULL );
alt_item->SetBack( NULL );
GetScreen()->Remove( item );
GetScreen()->Append( alt_item );
aList->SetPickedItem( alt_item, ii );
aList->SetPickedItemLink( item, ii );
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ),
//.........这里部分代码省略.........
示例7: GetScreen
//.........这里部分代码省略.........
break;
case ID_POPUP_END_LINE:
m_canvas->MoveCursorToCrossHair();
EndSegment( &dc );
break;
case ID_POPUP_SCH_BEGIN_WIRE:
m_canvas->MoveCursorToCrossHair();
OnLeftClick( &dc, GetCrossHairPosition() );
break;
case ID_POPUP_SCH_BEGIN_BUS:
m_canvas->MoveCursorToCrossHair();
OnLeftClick( &dc, GetCrossHairPosition() );
break;
case ID_POPUP_SCH_SET_SHAPE_TEXT:
// Not used
break;
case ID_POPUP_SCH_DELETE_NODE:
case ID_POPUP_SCH_DELETE_CONNECTION:
m_canvas->MoveCursorToCrossHair();
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION );
screen->SetCurItem( NULL );
SetRepeatItem( NULL );
screen->TestDanglingEnds( m_canvas, &dc );
m_canvas->Refresh();
break;
case ID_POPUP_SCH_BREAK_WIRE:
{
DLIST< SCH_ITEM > oldWires;
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
m_canvas->MoveCursorToCrossHair();
screen->ExtractWires( oldWires, true );
screen->BreakSegment( GetCrossHairPosition() );
if( oldWires.GetCount() != 0 )
{
PICKED_ITEMS_LIST oldItems;
oldItems.m_Status = UR_WIRE_IMAGE;
while( oldWires.GetCount() != 0 )
{
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
oldItems.PushItem( picker );
}
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
}
screen->TestDanglingEnds( m_canvas, &dc );
}
break;
case ID_POPUP_SCH_DELETE_CMP:
case ID_POPUP_SCH_DELETE:
if( item == NULL )
break;
DeleteItem( item );
screen->SetCurItem( NULL );
示例8: DrawSegment
/**
* Mouse capture callback for drawing line segments.
*/
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
SCH_LINE* segment;
if( s_wires.GetCount() == 0 )
return;
segment = (SCH_LINE*) s_wires.begin();
EDA_COLOR_T color = GetLayerColor( segment->GetLayer() );
ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) );
if( aErase )
{
while( segment )
{
if( !segment->IsNull() ) // Redraw if segment length != 0
segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color );
segment = segment->Next();
}
}
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent();
wxPoint endpos = frame->GetCrossHairPosition();
if( frame->GetForceHVLines() ) /* Coerce the line to vertical or horizontal one: */
ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos );
else
( (SCH_LINE*) s_wires.GetLast() )->SetEndPoint( endpos );
segment = (SCH_LINE*) s_wires.begin();
while( segment )
{
if( !segment->IsNull() ) // Redraw if segment length != 0
segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color );
segment = segment->Next();
}
}
示例9: AbortCreateNewLine
/* Abort function for wire, bus or line creation
*/
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC )
{
SCH_SCREEN* screen = (SCH_SCREEN*) Panel->GetScreen();
if( screen->GetCurItem() )
{
s_wires.DeleteAll();
s_oldWires.DeleteAll();
screen->SetCurItem( NULL );
Panel->Refresh();
}
else
{
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent();
parent->SetRepeatItem( NULL );
}
// Clear flags used in edit functions.
screen->ClearDrawingState();
}
示例10: BeginSegment
void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
{
SCH_LINE* segment;
SCH_LINE* nextSegment;
wxPoint cursorpos = GetCrossHairPosition();
// We should know if a segment is currently in progress
segment = (SCH_LINE*) GetScreen()->GetCurItem();
if( segment ) // a current item exists, but not necessary a currently edited item
{
if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) )
{
if( segment->GetFlags() )
{
wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ),
segment->GetFlags() );
}
// no wire, bus or graphic line in progress
segment = NULL;
}
}
if( !segment ) // first point : Create the first wire or bus segment
{
switch( type )
{
default:
segment = new SCH_LINE( cursorpos, LAYER_NOTES );
break;
case LAYER_WIRE:
segment = new SCH_LINE( cursorpos, LAYER_WIRE );
/* A junction will be created later, when we'll know the
* segment end position, and if the junction is really needed */
break;
case LAYER_BUS:
segment = new SCH_LINE( cursorpos, LAYER_BUS );
break;
}
segment->SetFlags( IS_NEW );
s_wires.PushBack( segment );
GetScreen()->SetCurItem( segment );
// We need 2 segments to go from a given start pin to an end point when the horizontal
// and vertical lines only switch is on.
if( GetForceHVLines() )
{
nextSegment = new SCH_LINE( *segment );
nextSegment->SetFlags( IS_NEW );
s_wires.PushBack( nextSegment );
GetScreen()->SetCurItem( nextSegment );
}
m_canvas->SetMouseCapture( DrawSegment, AbortCreateNewLine );
SetRepeatItem( NULL );
}
else // A segment is in progress: terminates the current segment and add a new segment.
{
SCH_LINE* prevSegment = segment->Back();
// Be aware prevSegment can be null when the horizontal and vertical lines only switch is off
// when we create the first segment.
if( !GetForceHVLines() )
{
// If only one segment is needed and it has a zero length, do not create a new one.
if( segment->IsNull() )
return;
}
else
{
wxCHECK_RET( prevSegment != NULL, wxT( "Failed to create second line segment." ) );
// If two segments are required and they both have zero length, do not
// create a new one.
if( prevSegment && prevSegment->IsNull() && segment->IsNull() )
return;
}
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
// Terminate the command if the end point is on a pin, junction, or another wire or bus.
if( GetScreen()->IsTerminalPoint( cursorpos, segment->GetLayer() ) )
{
EndSegment( DC );
return;
}
// Create a new segment, and chain it after the current new segment.
nextSegment = new SCH_LINE( *segment );
nextSegment->SetStartPoint( cursorpos );
s_wires.PushBack( nextSegment );
segment->SetEndPoint( cursorpos );
segment->ClearFlags( IS_NEW );
segment->SetFlags( SELECTED );
nextSegment->SetFlags( IS_NEW );
//.........这里部分代码省略.........