本文整理汇总了C++中PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList方法的典型用法代码示例。如果您正苦于以下问题:C++ PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList方法的具体用法?C++ PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList怎么用?C++ PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PCB_BASE_EDIT_FRAME
的用法示例。
在下文中一共展示了PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Main
//.........这里部分代码省略.........
// Flip causes change of layers
enableUpdateFlag( KIGFX::VIEW_ITEM::LAYERS );
}
else if( evt->IsAction( &COMMON_ACTIONS::remove ) )
{
Remove( aEvent );
break; // exit the loop, as there is no further processing for removed items
}
}
else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
{
m_cursor = controls->GetCursorPosition();
if( m_dragging )
{
wxPoint movement = wxPoint( m_cursor.x, m_cursor.y ) -
selection.Item<BOARD_ITEM>( 0 )->GetPosition();
// Drag items to the current cursor position
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
selection.Item<BOARD_ITEM>( i )->Move( movement + m_offset );
updateRatsnest( true );
}
else // Prepare to start dragging
{
if( m_selectionTool->CheckLock() || selection.Empty() )
break;
// Save items, so changes can be undone
editFrame->OnModify();
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
if( selection.Size() == 1 )
{
// Set the current cursor position to the first dragged item origin, so the
// movement vector could be computed later
m_cursor = VECTOR2I( selection.Item<BOARD_ITEM>( 0 )->GetPosition() );
m_offset.x = 0;
m_offset.y = 0;
}
else
{
VECTOR2D origin;
if( evt->IsDrag( BUT_LEFT ) )
origin = getView()->GetGAL()->GetGridPoint( evt->DragOrigin() );
else
origin = getViewControls()->GetCursorPosition();
// Update dragging offset (distance between cursor and the first dragged item)
m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() -
wxPoint( origin.x, origin.y );
}
controls->SetAutoPan( true );
m_dragging = true;
}
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
}
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
break; // Finish
}
m_dragging = false;
m_offset.x = 0;
m_offset.y = 0;
if( restore )
{
// Modifications have to be rollbacked, so restore the previous state of items
wxCommandEvent dummy;
editFrame->RestoreCopyFromUndoList( dummy );
}
else
{
// Changes are applied, so update the items
selection.group->ItemsViewUpdate( m_updateFlag );
}
if( unselect )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
ratsnest->ClearSimple();
ratsnest->Recalculate();
controls->ShowCursor( false );
controls->SetSnapping( false );
controls->SetAutoPan( false );
setTransitions();
return 0;
}
示例2: Main
//.........这里部分代码省略.........
incUndoInhibit();
}
}
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
}
// Dispatch TOOL_ACTIONs
else if( evt->Category() == TC_COMMAND )
{
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
{
Rotate( aEvent );
}
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
{
Flip( aEvent );
// Flip causes change of layers
enableUpdateFlag( KIGFX::VIEW_ITEM::LAYERS );
}
else if( evt->IsAction( &COMMON_ACTIONS::remove ) )
{
Remove( aEvent );
break; // exit the loop, as there is no further processing for removed items
}
else if( evt->IsAction( &COMMON_ACTIONS::duplicate ) )
{
// On duplicate, stop moving this item
// The duplicate tool should then select the new item and start
// a new move procedure
break;
}
else if( evt->IsAction( &COMMON_ACTIONS::moveExact ) )
{
// Can't do this, because the selection will then contain
// stale pointers and it will all go horribly wrong...
//editFrame->RestoreCopyFromUndoList( dummy );
//
// So, instead, reset the position manually
for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
{
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
item->SetPosition( item->GetPosition() - totalMovement );
// And what about flipping and rotation?
// for now, they won't be undone, but maybe that is how
// it should be, so you can flip and move exact in the
// same action?
}
// This causes a double event, so we will get the dialogue
// correctly, somehow - why does Rotate not?
//MoveExact( aEvent );
break; // exit the loop - we move exactly, so we have finished moving
}
}
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
{
if( !lockOverride )
break; // Finish
lockOverride = false;
}
} while( evt = Wait() );
if( m_dragging )
decUndoInhibit();
m_dragging = false;
m_offset.x = 0;
m_offset.y = 0;
if( restore )
{
// Modifications have to be rollbacked, so restore the previous state of items
wxCommandEvent dummy;
editFrame->RestoreCopyFromUndoList( dummy );
}
else
{
// Changes are applied, so update the items
selection.group->ItemsViewUpdate( m_updateFlag );
}
if( unselect )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
ratsnest->ClearSimple();
ratsnest->Recalculate();
controls->ShowCursor( false );
controls->SetAutoPan( false );
return 0;
}
示例3: OnSelectionChange
//.........这里部分代码省略.........
setEditedPoint( point );
}
else if( evt->IsAction( &COMMON_ACTIONS::pointEditorAddCorner ) )
{
addCorner( controls->GetCursorPosition() );
updatePoints();
}
else if( evt->IsAction( &COMMON_ACTIONS::pointEditorRemoveCorner ) )
{
if( m_editedPoint )
{
removeCorner( m_editedPoint );
updatePoints();
}
}
else if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
{
if( !modified )
{
// Save items, so changes can be undone
editFrame->OnModify();
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
controls->ForceCursorPosition( false );
m_original = *m_editedPoint; // Save the original position
controls->SetAutoPan( true );
modified = true;
}
bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
setAltConstraint( enableAltConstraint );
m_editedPoint->SetPosition( controls->GetCursorPosition() );
if( m_altConstraint )
m_altConstraint->Apply();
else
m_editedPoint->ApplyConstraint();
updateItem();
updatePoints();
m_editPoints->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
else if( evt->IsAction( &COMMON_ACTIONS::pointEditorUpdate ) )
{
updatePoints();
}
else if( evt->IsMouseUp( BUT_LEFT ) )
{
controls->SetAutoPan( false );
setAltConstraint( false );
modified = false;
m_toolMgr->PassEvent();
}
else if( evt->IsCancel() )
{
if( modified ) // Restore the last change
{
wxCommandEvent dummy;
editFrame->RestoreCopyFromUndoList( dummy );
updatePoints();
modified = false;
}
// Let the selection tool receive the event too
m_toolMgr->PassEvent();
break;
}
else
{
m_toolMgr->PassEvent();
}
}
if( m_editPoints )
{
finishItem();
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
view->Remove( m_editPoints.get() );
m_editPoints.reset();
}
controls->ShowCursor( false );
controls->SetAutoPan( false );
controls->SetSnapping( false );
controls->ForceCursorPosition( false );
}
return 0;
}