Removed a number 'if(m_editModules)' sections from pcbnew tools.
This commit is contained in:
parent
c78faec247
commit
ff6bdeee4b
|
@ -66,52 +66,27 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
|
|||
m_view = getView();
|
||||
m_controls = getViewControls();
|
||||
m_board = getModel<BOARD>();
|
||||
m_frame = getEditFrame<PCB_EDIT_FRAME>();
|
||||
m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
|
||||
DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
|
||||
boost::optional<VECTOR2D> startingPoint;
|
||||
|
||||
if( m_editModules )
|
||||
{
|
||||
m_frame->SetToolID( ID_MODEDIT_LINE_TOOL, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||
|
||||
EDGE_MODULE* line = new EDGE_MODULE( m_board->m_Modules );
|
||||
|
||||
while( drawSegment( S_SEGMENT, reinterpret_cast<DRAWSEGMENT*&>( line ), startingPoint ) )
|
||||
{
|
||||
if( line )
|
||||
{
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
line->SetParent( m_board->m_Modules );
|
||||
line->SetLocalCoord();
|
||||
m_board->m_Modules->GraphicalItems().PushFront( line );
|
||||
startingPoint = line->GetEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
startingPoint = boost::none;
|
||||
}
|
||||
|
||||
line = new EDGE_MODULE( m_board->m_Modules );
|
||||
}
|
||||
}
|
||||
else // !m_editModules case
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_ADD_LINE_BUTT, wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||
|
||||
DRAWSEGMENT* line = new DRAWSEGMENT;
|
||||
m_frame->SetToolID( m_editModules ? ID_MODEDIT_LINE_TOOL : ID_PCB_ADD_LINE_BUTT,
|
||||
wxCURSOR_PENCIL, _( "Add graphic line" ) );
|
||||
|
||||
while( drawSegment( S_SEGMENT, line, startingPoint ) )
|
||||
{
|
||||
if( line )
|
||||
{
|
||||
m_board->Add( line );
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( line, UR_NEW );
|
||||
|
||||
parent->Add( line );
|
||||
startingPoint = line->GetEnd();
|
||||
}
|
||||
else
|
||||
|
@ -119,8 +94,7 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
|||
startingPoint = boost::none;
|
||||
}
|
||||
|
||||
line = new DRAWSEGMENT;
|
||||
}
|
||||
line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
|
||||
}
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
@ -131,43 +105,23 @@ int DRAWING_TOOL::DrawLine( const TOOL_EVENT& aEvent )
|
|||
|
||||
int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( m_editModules )
|
||||
{
|
||||
m_frame->SetToolID( ID_MODEDIT_CIRCLE_TOOL, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
|
||||
DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
|
||||
|
||||
EDGE_MODULE* circle = new EDGE_MODULE( m_board->m_Modules );
|
||||
|
||||
while( drawSegment( S_CIRCLE, reinterpret_cast<DRAWSEGMENT*&>( circle ) ) )
|
||||
{
|
||||
if( circle )
|
||||
{
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
circle->SetParent( m_board->m_Modules );
|
||||
circle->SetLocalCoord();
|
||||
m_board->m_Modules->GraphicalItems().PushFront( circle );
|
||||
}
|
||||
|
||||
circle = new EDGE_MODULE( m_board->m_Modules );
|
||||
}
|
||||
}
|
||||
else // !m_editModules case
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||
|
||||
DRAWSEGMENT* circle = new DRAWSEGMENT;
|
||||
m_frame->SetToolID( m_editModules ? ID_MODEDIT_CIRCLE_TOOL : ID_PCB_CIRCLE_BUTT,
|
||||
wxCURSOR_PENCIL, _( "Add graphic circle" ) );
|
||||
|
||||
while( drawSegment( S_CIRCLE, circle ) )
|
||||
{
|
||||
if( circle )
|
||||
{
|
||||
m_board->Add( circle );
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( circle, UR_NEW );
|
||||
|
||||
m_frame->GetModel()->Add( circle );
|
||||
}
|
||||
|
||||
circle = new DRAWSEGMENT;
|
||||
}
|
||||
circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
|
||||
}
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
@ -178,43 +132,23 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
|
|||
|
||||
int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( m_editModules )
|
||||
{
|
||||
m_frame->SetToolID( ID_MODEDIT_ARC_TOOL, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
|
||||
DRAWSEGMENT* arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
|
||||
|
||||
EDGE_MODULE* arc = new EDGE_MODULE( m_board->m_Modules );
|
||||
|
||||
while( drawArc( reinterpret_cast<DRAWSEGMENT*&>( arc ) ) )
|
||||
{
|
||||
if( arc )
|
||||
{
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
arc->SetParent( m_board->m_Modules );
|
||||
arc->SetLocalCoord();
|
||||
m_board->m_Modules->GraphicalItems().PushFront( arc );
|
||||
}
|
||||
|
||||
arc = new EDGE_MODULE( m_board->m_Modules );
|
||||
}
|
||||
}
|
||||
else // !m_editModules case
|
||||
{
|
||||
m_frame->SetToolID( ID_PCB_ARC_BUTT, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||
|
||||
DRAWSEGMENT* arc = new DRAWSEGMENT;
|
||||
m_frame->SetToolID( m_editModules ? ID_MODEDIT_ARC_TOOL : ID_PCB_ARC_BUTT,
|
||||
wxCURSOR_PENCIL, _( "Add graphic arc" ) );
|
||||
|
||||
while( drawArc( arc ) )
|
||||
{
|
||||
if( arc )
|
||||
{
|
||||
m_board->Add( arc );
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( arc, UR_NEW );
|
||||
|
||||
m_frame->GetModel()->Add( arc );
|
||||
}
|
||||
|
||||
arc = new DRAWSEGMENT;
|
||||
}
|
||||
arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
|
||||
}
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
@ -225,10 +159,147 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
|
|||
|
||||
int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( m_editModules )
|
||||
return placeTextModule();
|
||||
BOARD_ITEM* text = NULL;
|
||||
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
||||
|
||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||
KIGFX::VIEW_GROUP preview( m_view );
|
||||
m_view->Add( &preview );
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
// do not capture or auto-pan until we start placing some text
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( m_editModules ? ID_MODEDIT_TEXT_TOOL : ID_PCB_ADD_TEXT_BUTT,
|
||||
wxCURSOR_PENCIL, _( "Add text" ) );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
if( evt->IsCancel() || evt->IsActivate() )
|
||||
{
|
||||
if( text )
|
||||
{
|
||||
// Delete the old text and have another try
|
||||
m_frame->GetModel()->Delete( text ); // it was already added by CreateTextPcb()
|
||||
text = NULL;
|
||||
|
||||
preview.Clear();
|
||||
preview.ViewUpdate();
|
||||
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->ShowCursor( true );
|
||||
}
|
||||
else
|
||||
return placeTextPcb();
|
||||
break;
|
||||
|
||||
if( evt->IsActivate() ) // now finish unconditionally
|
||||
break;
|
||||
}
|
||||
|
||||
else if( text && evt->Category() == TC_COMMAND )
|
||||
{
|
||||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate();
|
||||
}
|
||||
// TODO rotate CCW
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
text->Flip( text->GetPosition() );
|
||||
preview.ViewUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
if( !text )
|
||||
{
|
||||
// Init the new item attributes
|
||||
if( m_editModules )
|
||||
{
|
||||
TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
|
||||
textMod->SetSize( dsnSettings.m_ModuleTextSize );
|
||||
textMod->SetThickness( dsnSettings.m_ModuleTextWidth );
|
||||
textMod->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
DialogEditModuleText textDialog( m_frame, textMod, NULL );
|
||||
bool placing = textDialog.ShowModal() && ( textMod->GetText().Length() > 0 );
|
||||
|
||||
if( placing )
|
||||
text = textMod;
|
||||
else
|
||||
delete textMod;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( !m_editModules );
|
||||
text = static_cast<PCB_EDIT_FRAME*>( m_frame )->CreateTextePcb( NULL );
|
||||
}
|
||||
|
||||
if( text == NULL )
|
||||
continue;
|
||||
|
||||
m_controls->CaptureCursor( true );
|
||||
m_controls->SetAutoPan( true );
|
||||
//m_controls->ShowCursor( false );
|
||||
|
||||
preview.Add( text );
|
||||
}
|
||||
else
|
||||
{
|
||||
//assert( text->GetText().Length() > 0 );
|
||||
//assert( text->GetSize().x > 0 && text->GetSize().y > 0 );
|
||||
|
||||
text->ClearFlags();
|
||||
m_view->Add( text );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( text, UR_NEW );
|
||||
|
||||
if( m_editModules )
|
||||
{
|
||||
m_frame->GetModel()->Add( text );
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_board->Add( text ); // it is already added by CreateTextePcb()
|
||||
}
|
||||
|
||||
preview.Remove( text );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->ShowCursor( true );
|
||||
|
||||
text = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
else if( text && evt->IsMotion() )
|
||||
{
|
||||
text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
// Show a preview of the item
|
||||
preview.ViewUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
|
||||
m_view->Remove( &preview );
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,13 +422,12 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
assert( dimension->GetOrigin() != dimension->GetEnd() );
|
||||
assert( dimension->GetWidth() > 0 );
|
||||
|
||||
m_view->Add( dimension );
|
||||
m_board->Add( dimension );
|
||||
//dimension->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( dimension, UR_NEW );
|
||||
|
||||
m_view->Add( dimension );
|
||||
m_board->Add( dimension );
|
||||
|
||||
preview.Remove( dimension );
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +501,7 @@ int DRAWING_TOOL::DrawKeepout( const TOOL_EVENT& aEvent )
|
|||
|
||||
int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( m_editModules && !m_board->m_Modules )
|
||||
if( !m_frame->GetModel() )
|
||||
return 0;
|
||||
|
||||
DIALOG_DXF_IMPORT dlg( m_frame );
|
||||
|
@ -509,33 +579,32 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
|||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
// Place the drawing
|
||||
if( m_editModules )
|
||||
{
|
||||
assert( m_board->m_Modules );
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
m_board->m_Modules->SetLastEditTime();
|
||||
PICKED_ITEMS_LIST picklist;
|
||||
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
|
||||
|
||||
for( KIGFX::VIEW_GROUP::const_iter it = preview.Begin(), end = preview.End(); it != end; ++it )
|
||||
for( KIGFX::VIEW_GROUP::const_iter it = preview.Begin(); it != preview.End(); ++it )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
|
||||
BOARD_ITEM* converted = NULL;
|
||||
|
||||
if( m_editModules )
|
||||
{
|
||||
// Modules use different types for the same things,
|
||||
// so we need to convert imported items to appropriate classes.
|
||||
BOARD_ITEM* converted = NULL;
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_TEXT_T:
|
||||
converted = new TEXTE_MODULE( m_board->m_Modules );
|
||||
converted = new TEXTE_MODULE( (MODULE*) parent );
|
||||
|
||||
// Copy coordinates, layer, etc.
|
||||
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
|
||||
static_cast<TEXTE_MODULE*>( converted )->SetLocalCoord();
|
||||
*static_cast<BOARD_ITEM*>( converted ) = *static_cast<BOARD_ITEM*>( item );
|
||||
break;
|
||||
|
||||
case PCB_LINE_T:
|
||||
converted = new EDGE_MODULE( m_board->m_Modules );
|
||||
converted = new EDGE_MODULE( (MODULE*) parent );
|
||||
// Copy coordinates, layer, etc.
|
||||
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
|
||||
static_cast<EDGE_MODULE*>( converted )->SetLocalCoord();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -544,33 +613,23 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
delete item;
|
||||
|
||||
if( converted )
|
||||
{
|
||||
m_board->m_Modules->Add( converted );
|
||||
m_view->Add( converted );
|
||||
item = converted;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // !m_editModules case
|
||||
{
|
||||
PICKED_ITEMS_LIST picklist;
|
||||
|
||||
for( KIGFX::VIEW_GROUP::const_iter it = preview.Begin(), end = preview.End(); it != end; ++it )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
|
||||
m_board->Add( item );
|
||||
|
||||
ITEM_PICKER itemWrapper( item, UR_NEW );
|
||||
picklist.PushItem( itemWrapper );
|
||||
|
||||
m_view->Add( item );
|
||||
}
|
||||
|
||||
m_frame->SaveCopyInUndoList( picklist, UR_NEW );
|
||||
}
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( picklist, UR_NEW );
|
||||
|
||||
for( KIGFX::VIEW_GROUP::const_iter it = preview.Begin(); it != preview.End(); ++it )
|
||||
{
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
|
||||
parent->Add( item );
|
||||
m_view->Add( item );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -604,15 +663,16 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
m_board->m_Modules->SetLastEditTime();
|
||||
MODULE* module = (MODULE*) m_frame->GetModel();
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( module, UR_CHANGED );
|
||||
|
||||
// set the new relative internal local coordinates of footprint items
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
wxPoint moveVector = m_board->m_Modules->GetPosition() - wxPoint( cursorPos.x, cursorPos.y );
|
||||
m_board->m_Modules->MoveAnchorPosition( moveVector );
|
||||
|
||||
m_board->m_Modules->ViewUpdate();
|
||||
wxPoint moveVector = module->GetPosition() - wxPoint( cursorPos.x, cursorPos.y );
|
||||
module->MoveAnchorPosition( moveVector );
|
||||
module->ViewUpdate();
|
||||
|
||||
// Usually, we do not need to change twice the anchor position,
|
||||
// so deselect the active tool
|
||||
|
@ -747,38 +807,22 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
|
|||
( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT ) )
|
||||
// User has clicked twice in the same spot
|
||||
{ // a clear sign that the current drawing is finished
|
||||
// Now we have to add the helper line as well
|
||||
if( direction45 )
|
||||
{
|
||||
// Now we have to add the helper line as well
|
||||
if( m_editModules )
|
||||
{
|
||||
EDGE_MODULE* l = new EDGE_MODULE( m_board->m_Modules );
|
||||
BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
|
||||
DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( (MODULE*) parent )
|
||||
: new DRAWSEGMENT;
|
||||
|
||||
// Copy coordinates, layer, etc.
|
||||
*static_cast<DRAWSEGMENT*>( l ) = line45;
|
||||
l->SetEnd( aGraphic->GetStart() );
|
||||
l->SetLocalCoord();
|
||||
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
m_board->m_Modules->SetLastEditTime();
|
||||
m_board->m_Modules->GraphicalItems().PushFront( l );
|
||||
|
||||
m_view->Add( l );
|
||||
l->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
else
|
||||
{
|
||||
DRAWSEGMENT* l = static_cast<DRAWSEGMENT*>( line45.Clone() );
|
||||
l->SetEnd( aGraphic->GetStart() );
|
||||
|
||||
m_frame->SaveCopyInUndoList( l, UR_NEW );
|
||||
m_board->Add( l );
|
||||
|
||||
m_view->Add( l );
|
||||
l->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( l, UR_NEW );
|
||||
|
||||
parent->Add( l );
|
||||
m_view->Add( l );
|
||||
}
|
||||
|
||||
delete aGraphic;
|
||||
|
@ -1110,6 +1154,9 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
|
|||
zone->Outline()->CloseLastContour();
|
||||
zone->Outline()->RemoveNullSegments();
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( zone, UR_NEW );
|
||||
|
||||
m_board->Add( zone );
|
||||
m_view->Add( zone );
|
||||
|
||||
|
@ -1119,9 +1166,6 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
|
|||
zone->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_board->GetRatsnest()->Update( zone );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( zone, UR_NEW );
|
||||
|
||||
zone = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -1238,248 +1282,6 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
|
|||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::placeTextModule()
|
||||
{
|
||||
TEXTE_MODULE* text = new TEXTE_MODULE( NULL );
|
||||
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
||||
|
||||
assert( m_editModules );
|
||||
|
||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||
KIGFX::VIEW_GROUP preview( m_view );
|
||||
m_view->Add( &preview );
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
// do not capture or auto-pan until we start placing some text
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_MODEDIT_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) );
|
||||
bool placing = false;
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
if( evt->IsCancel() || evt->IsActivate() )
|
||||
{
|
||||
preview.Clear();
|
||||
preview.ViewUpdate();
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->ShowCursor( true );
|
||||
|
||||
if( !placing || evt->IsActivate() )
|
||||
{
|
||||
delete text;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
placing = false; // start from the beginning
|
||||
}
|
||||
}
|
||||
|
||||
else if( text && evt->Category() == TC_COMMAND )
|
||||
{
|
||||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
text->Flip( text->GetPosition() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
if( !placing )
|
||||
{
|
||||
text->SetSize( dsnSettings.m_ModuleTextSize );
|
||||
text->SetThickness( dsnSettings.m_ModuleTextWidth );
|
||||
text->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
DialogEditModuleText textDialog( m_frame, text, NULL );
|
||||
placing = textDialog.ShowModal() && ( text->GetText().Length() > 0 );
|
||||
|
||||
if( !placing )
|
||||
continue;
|
||||
|
||||
m_controls->CaptureCursor( true );
|
||||
m_controls->SetAutoPan( true );
|
||||
m_controls->ShowCursor( false );
|
||||
text->SetParent( m_board->m_Modules ); // it has to set after the settings dialog
|
||||
// otherwise the dialog stores it in undo buffer
|
||||
preview.Add( text );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( text->GetText().Length() > 0 );
|
||||
assert( text->GetSize().x > 0 && text->GetSize().y > 0 );
|
||||
|
||||
text->SetLocalCoord();
|
||||
text->ClearFlags();
|
||||
|
||||
// Module has to be saved before any modification is made
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
m_board->m_Modules->SetLastEditTime();
|
||||
m_board->m_Modules->GraphicalItems().PushFront( text );
|
||||
|
||||
m_view->Add( text );
|
||||
text->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
m_frame->OnModify();
|
||||
|
||||
preview.Remove( text );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->ShowCursor( true );
|
||||
|
||||
text = new TEXTE_MODULE( NULL );
|
||||
placing = false;
|
||||
}
|
||||
}
|
||||
|
||||
else if( text && evt->IsMotion() )
|
||||
{
|
||||
text->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
// Show a preview of the item
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::placeTextPcb()
|
||||
{
|
||||
TEXTE_PCB* text = NULL;
|
||||
|
||||
assert( !m_editModules );
|
||||
|
||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||
KIGFX::VIEW_GROUP preview( m_view );
|
||||
m_view->Add( &preview );
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
m_controls->ShowCursor( true );
|
||||
m_controls->SetSnapping( true );
|
||||
// do not capture or auto-pan until we start placing some text
|
||||
|
||||
Activate();
|
||||
m_frame->SetToolID( ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
|
||||
|
||||
// Main loop: keep receiving events
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
||||
if( evt->IsCancel() || evt->IsActivate() )
|
||||
{
|
||||
if( text )
|
||||
{
|
||||
// Delete the old text and have another try
|
||||
m_board->Delete( text ); // it was already added by CreateTextPcb()
|
||||
text = NULL;
|
||||
|
||||
preview.Clear();
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->ShowCursor( true );
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
if( evt->IsActivate() ) // now finish unconditionally
|
||||
break;
|
||||
}
|
||||
|
||||
else if( text && evt->Category() == TC_COMMAND )
|
||||
{
|
||||
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
|
||||
{
|
||||
text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
|
||||
{
|
||||
text->Flip( text->GetPosition() );
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
if( !text )
|
||||
{
|
||||
// Init the new item attributes
|
||||
text = static_cast<PCB_EDIT_FRAME*>( m_frame )->CreateTextePcb( NULL );
|
||||
|
||||
if( text == NULL )
|
||||
continue;
|
||||
|
||||
m_controls->CaptureCursor( true );
|
||||
m_controls->SetAutoPan( true );
|
||||
preview.Add( text );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( text->GetText().Length() > 0 );
|
||||
assert( text->GetSize().x > 0 && text->GetSize().y > 0 );
|
||||
|
||||
text->ClearFlags();
|
||||
m_view->Add( text );
|
||||
// m_board->Add( text ); // it is already added by CreateTextePcb()
|
||||
text->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( text, UR_NEW );
|
||||
|
||||
preview.Remove( text );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
|
||||
text = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
else if( text && evt->IsMotion() )
|
||||
{
|
||||
text->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
|
||||
// Show a preview of the item
|
||||
preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
}
|
||||
|
||||
m_controls->ShowCursor( false );
|
||||
m_controls->SetSnapping( false );
|
||||
m_controls->SetAutoPan( false );
|
||||
m_controls->CaptureCursor( false );
|
||||
m_view->Remove( &preview );
|
||||
|
||||
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DRAWING_TOOL::make45DegLine( DRAWSEGMENT* aSegment, DRAWSEGMENT* aHelper ) const
|
||||
{
|
||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace KIGFX
|
|||
class VIEW_CONTROLS;
|
||||
}
|
||||
class BOARD;
|
||||
class PCB_EDIT_FRAME;
|
||||
class PCB_BASE_EDIT_FRAME;
|
||||
class DRAWSEGMENT;
|
||||
|
||||
/**
|
||||
|
@ -156,20 +156,6 @@ private:
|
|||
///> @param aKeepout decides if the drawn polygon is a zone or a keepout area.
|
||||
int drawZone( bool aKeepout );
|
||||
|
||||
/**
|
||||
* Function placeTextModule()
|
||||
* Displays a dialog that allows to input text and its settings and then lets the user decide
|
||||
* where to place the text in module .
|
||||
*/
|
||||
int placeTextModule();
|
||||
|
||||
/**
|
||||
* Function placeTextPcb()
|
||||
* Displays a dialog that allows to input text and its settings and then lets the user decide
|
||||
* where to place the text in board editor.
|
||||
*/
|
||||
int placeTextPcb();
|
||||
|
||||
/**
|
||||
* Function make45DegLine()
|
||||
* Forces a DRAWSEGMENT to be drawn at multiple of 45 degrees. The origin stays the same,
|
||||
|
@ -185,7 +171,7 @@ private:
|
|||
KIGFX::VIEW* m_view;
|
||||
KIGFX::VIEW_CONTROLS* m_controls;
|
||||
BOARD* m_board;
|
||||
PCB_EDIT_FRAME* m_frame;
|
||||
PCB_BASE_EDIT_FRAME* m_frame;
|
||||
|
||||
/// Edit module mode flag
|
||||
bool m_editModules;
|
||||
|
|
|
@ -533,10 +533,6 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
// As we are about to remove items, they have to be removed from the selection first
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
|
||||
// Save them
|
||||
for( unsigned int i = 0; i < selectedItems.GetCount(); ++i )
|
||||
selectedItems.SetPickedItemStatus( UR_DELETED, i );
|
||||
|
||||
editFrame->OnModify();
|
||||
editFrame->SaveCopyInUndoList( selectedItems, UR_DELETED );
|
||||
|
||||
|
@ -588,38 +584,10 @@ void EDIT_TOOL::remove( BOARD_ITEM* aItem )
|
|||
case TEXTE_MODULE::TEXT_is_DIVERS: // suppress warnings
|
||||
break;
|
||||
}
|
||||
|
||||
if( m_editModules )
|
||||
{
|
||||
MODULE* module = static_cast<MODULE*>( aItem->GetParent() );
|
||||
module->SetLastEditTime();
|
||||
board->m_Status_Pcb = 0; // it is done in the legacy view
|
||||
aItem->DeleteStructure();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case PCB_PAD_T:
|
||||
case PCB_MODULE_EDGE_T:
|
||||
{
|
||||
MODULE* module = static_cast<MODULE*>( aItem->GetParent() );
|
||||
module->SetLastEditTime();
|
||||
|
||||
board->m_Status_Pcb = 0; // it is done in the legacy view
|
||||
|
||||
|
||||
if( !m_editModules )
|
||||
{
|
||||
getView()->Remove( aItem );
|
||||
board->Remove( aItem );
|
||||
}
|
||||
|
||||
aItem->DeleteStructure();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -637,7 +605,7 @@ void EDIT_TOOL::remove( BOARD_ITEM* aItem )
|
|||
}
|
||||
|
||||
getView()->Remove( aItem );
|
||||
board->Remove( aItem );
|
||||
getEditFrame<PCB_EDIT_FRAME>()->GetModel()->Remove( aItem );
|
||||
}
|
||||
|
||||
|
||||
|
@ -723,10 +691,6 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
|||
// the original
|
||||
incUndoInhibit();
|
||||
|
||||
// TODO remove the following when undo buffer handles UR_NEW
|
||||
if( m_editModules )
|
||||
editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_CHANGED );
|
||||
|
||||
std::vector<BOARD_ITEM*> old_items;
|
||||
|
||||
for( int i = 0; i < selection.Size(); ++i )
|
||||
|
@ -748,6 +712,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
|||
|
||||
BOARD_ITEM* new_item = NULL;
|
||||
|
||||
// TODO move DuplicateAndAddItem() to BOARD_ITEM_CONTAINER? dunno..
|
||||
if( m_editModules )
|
||||
new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
|
||||
else
|
||||
|
@ -777,8 +742,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
// record the new items as added
|
||||
// TODO remove m_editModules condition when undo buffer handles UR_NEW)
|
||||
if( !m_editModules && !selection.Empty() )
|
||||
if( !selection.Empty() )
|
||||
{
|
||||
editFrame->SaveCopyInUndoList( selection.items, UR_NEW );
|
||||
|
||||
|
|
|
@ -158,16 +158,10 @@ int MODULE_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
|
|||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_CHANGED );
|
||||
m_frame->SaveCopyInUndoList( pad, UR_NEW );
|
||||
|
||||
m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
||||
pad->SetParent( m_board->m_Modules );
|
||||
m_board->m_Modules->SetLastEditTime();
|
||||
m_board->m_Modules->Pads().PushBack( pad );
|
||||
|
||||
// Set the relative pad position
|
||||
// ( pad position for module orient, 0, and relative to the module position)
|
||||
pad->SetLocalCoord();
|
||||
m_frame->GetModel()->Add( pad );
|
||||
|
||||
// Take the next available pad number
|
||||
pad->IncrementPadName( true, true );
|
||||
|
@ -479,7 +473,6 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
m_frame->SaveCopyInUndoList( currentModule, UR_CHANGED );
|
||||
|
||||
m_board->m_Status_Pcb = 0; // I have no clue why, but it is done in the legacy view
|
||||
currentModule->SetLastEditTime();
|
||||
|
||||
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
|
||||
// directly modify them
|
||||
|
@ -487,9 +480,7 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
for( D_PAD* pad = pastedModule->Pads(); pad; pad = pad->Next() )
|
||||
{
|
||||
D_PAD* clone = static_cast<D_PAD*>( pad->Clone() );
|
||||
|
||||
currentModule->Add( clone );
|
||||
clone->SetLocalCoord();
|
||||
m_view->Add( clone );
|
||||
}
|
||||
|
||||
|
@ -503,7 +494,6 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
// Do not add reference/value - convert them to the common type
|
||||
text->SetType( TEXTE_MODULE::TEXT_is_DIVERS );
|
||||
currentModule->Add( text );
|
||||
text->SetLocalCoord();
|
||||
|
||||
// Whyyyyyyyyyyyyyyyyyyyyyy?! All other items conform to rotation performed
|
||||
// on its parent module, but texts are so independent..
|
||||
|
@ -512,7 +502,6 @@ int MODULE_TOOLS::PasteItems( const TOOL_EVENT& aEvent )
|
|||
else if( EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( clone ) )
|
||||
{
|
||||
currentModule->Add( edge );
|
||||
edge->SetLocalCoord();
|
||||
}
|
||||
|
||||
m_view->Add( clone );
|
||||
|
|
|
@ -298,14 +298,14 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( module, UR_NEW );
|
||||
|
||||
// Place the selected module
|
||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1 ) );
|
||||
view->Add( module );
|
||||
module->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( module, UR_NEW );
|
||||
|
||||
// Remove from preview
|
||||
preview.Remove( module );
|
||||
module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
|
||||
|
@ -454,13 +454,13 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|||
assert( target->GetSize() > 0 );
|
||||
assert( target->GetWidth() > 0 );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( target, UR_NEW );
|
||||
|
||||
view->Add( target );
|
||||
board->Add( target );
|
||||
target->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
m_frame->OnModify();
|
||||
m_frame->SaveCopyInUndoList( target, UR_NEW );
|
||||
|
||||
preview.Remove( target );
|
||||
|
||||
// Create next PCB_TARGET
|
||||
|
|
|
@ -771,7 +771,6 @@ int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent )
|
|||
int open_ctl;
|
||||
wxString fileName;
|
||||
PICKED_ITEMS_LIST undoListPicker;
|
||||
ITEM_PICKER picker( NULL, UR_NEW );
|
||||
|
||||
PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
|
||||
BOARD* board = getModel<BOARD>();
|
||||
|
@ -839,8 +838,7 @@ int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent )
|
|||
continue;
|
||||
}
|
||||
|
||||
picker.SetItem( track );
|
||||
undoListPicker.PushItem( picker );
|
||||
undoListPicker.PushItem( ITEM_PICKER( track, UR_NEW ) );
|
||||
view->Add( track );
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, track );
|
||||
}
|
||||
|
@ -849,11 +847,11 @@ int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( ; module; module = module->Next() )
|
||||
{
|
||||
picker.SetItem( module );
|
||||
undoListPicker.PushItem( picker );
|
||||
undoListPicker.PushItem( ITEM_PICKER( module, UR_NEW ) );
|
||||
|
||||
module->RunOnChildren( std::bind( &KIGFX::VIEW::Add, view, _1 ) );
|
||||
view->Add( module );
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, module );
|
||||
}
|
||||
|
||||
|
@ -861,8 +859,7 @@ int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent )
|
|||
|
||||
for( ; drawing; drawing = drawing->Next() )
|
||||
{
|
||||
picker.SetItem( drawing );
|
||||
undoListPicker.PushItem( picker );
|
||||
undoListPicker.PushItem( ITEM_PICKER( drawing, UR_NEW ) );
|
||||
view->Add( drawing );
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, drawing );
|
||||
}
|
||||
|
@ -870,8 +867,7 @@ int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent )
|
|||
for( ZONE_CONTAINER* zone = board->GetArea( zonescount ); zone;
|
||||
zone = board->GetArea( zonescount ) )
|
||||
{
|
||||
picker.SetItem( zone );
|
||||
undoListPicker.PushItem( picker );
|
||||
undoListPicker.PushItem( ITEM_PICKER( zone, UR_NEW ) );
|
||||
zonescount++;
|
||||
view->Add( zone );
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, zone );
|
||||
|
|
|
@ -292,9 +292,9 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
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 );
|
||||
|
@ -720,11 +720,12 @@ void POINT_EDITOR::addCorner( const VECTOR2I& aBreakPoint )
|
|||
{
|
||||
EDA_ITEM* item = m_editPoints->GetParent();
|
||||
const SELECTION& selection = m_selectionTool->GetSelection();
|
||||
PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
|
||||
if( item->Type() == PCB_ZONE_AREA_T )
|
||||
{
|
||||
getEditFrame<PCB_BASE_FRAME>()->OnModify();
|
||||
getEditFrame<PCB_BASE_FRAME>()->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
||||
frame->OnModify();
|
||||
frame->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
||||
|
||||
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
|
||||
CPolyLine* outline = zone->Outline();
|
||||
|
@ -765,15 +766,14 @@ void POINT_EDITOR::addCorner( const VECTOR2I& aBreakPoint )
|
|||
else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T )
|
||||
{
|
||||
bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T;
|
||||
PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
|
||||
|
||||
frame->OnModify();
|
||||
frame->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
||||
|
||||
DRAWSEGMENT* segment = static_cast<DRAWSEGMENT*>( item );
|
||||
|
||||
if( segment->GetShape() == S_SEGMENT )
|
||||
{
|
||||
ITEM_PICKER old_segment( segment, UR_CHANGED );
|
||||
old_segment.SetLink( segment->Clone() );
|
||||
|
||||
SEG seg( segment->GetStart(), segment->GetEnd() );
|
||||
VECTOR2I nearestPoint = seg.NearestPoint( aBreakPoint );
|
||||
|
||||
|
@ -786,9 +786,9 @@ void POINT_EDITOR::addCorner( const VECTOR2I& aBreakPoint )
|
|||
if( moduleEdge )
|
||||
{
|
||||
EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( segment );
|
||||
assert( segment->GetParent()->Type() == PCB_MODULE_T );
|
||||
assert( edge->Type() == PCB_MODULE_EDGE_T );
|
||||
assert( edge->GetParent()->Type() == PCB_MODULE_T );
|
||||
newSegment = new EDGE_MODULE( *edge );
|
||||
edge->SetLocalCoord();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -799,16 +799,13 @@ void POINT_EDITOR::addCorner( const VECTOR2I& aBreakPoint )
|
|||
newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
|
||||
newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) );
|
||||
|
||||
if( moduleEdge )
|
||||
{
|
||||
static_cast<EDGE_MODULE*>( newSegment )->SetLocalCoord();
|
||||
getModel<BOARD>()->m_Modules->Add( newSegment );
|
||||
}
|
||||
else
|
||||
{
|
||||
getModel<BOARD>()->Add( newSegment );
|
||||
}
|
||||
PICKED_ITEMS_LIST changes;
|
||||
changes.PushItem( old_segment );
|
||||
changes.PushItem( ITEM_PICKER( newSegment, UR_NEW ) );
|
||||
frame->OnModify();
|
||||
frame->SaveCopyInUndoList( changes, UR_UNSPECIFIED );
|
||||
|
||||
frame->GetModel()->Add( newSegment );
|
||||
getView()->Add( newSegment );
|
||||
}
|
||||
}
|
||||
|
@ -833,6 +830,7 @@ void POINT_EDITOR::removeCorner( EDIT_POINT* aPoint )
|
|||
{
|
||||
frame->OnModify();
|
||||
frame->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
||||
|
||||
outline->DeleteCorner( i );
|
||||
setEditedPoint( NULL );
|
||||
break;
|
||||
|
|
|
@ -360,11 +360,8 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag )
|
|||
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
||||
GENERAL_COLLECTOR collector;
|
||||
|
||||
if( m_editModules )
|
||||
collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::ModuleItems,
|
||||
wxPoint( aWhere.x, aWhere.y ), guide );
|
||||
else
|
||||
collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::AllBoardItems,
|
||||
collector.Collect( getModel<BOARD>(),
|
||||
m_editModules ? GENERAL_COLLECTOR::ModuleItems : GENERAL_COLLECTOR::AllBoardItems,
|
||||
wxPoint( aWhere.x, aWhere.y ), guide );
|
||||
|
||||
bool anyCollected = collector.GetCount() != 0;
|
||||
|
|
Loading…
Reference in New Issue