From 2b1d6b303a81f6b62f1d6a1f3ecae91e75a50ba5 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 15:02:56 +0200 Subject: [PATCH] Added support for module edge splitting with double click. --- pcbnew/tools/point_editor.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 64ad775a06..14e66424e3 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -40,6 +40,7 @@ #include #include #include +#include // Few constants to avoid using bare numbers for point indices enum SEG_POINTS @@ -710,8 +711,14 @@ void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint ) else if( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) { + bool moduleEdge = item->Type() == PCB_MODULE_EDGE_T; + getEditFrame()->OnModify(); - getEditFrame()->SaveCopyInUndoList( selection.items, UR_CHANGED ); + + if( moduleEdge ) + getEditFrame()->SaveCopyInUndoList( getModel()->m_Modules, UR_MODEDIT ); + else + getEditFrame()->SaveCopyInUndoList( selection.items, UR_CHANGED ); DRAWSEGMENT* segment = static_cast( item ); @@ -724,12 +731,34 @@ void POINT_EDITOR::breakOutline( const VECTOR2I& aBreakPoint ) segment->SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) ); // and add another one starting from the break point - DRAWSEGMENT* newSegment = new DRAWSEGMENT( *segment ); + DRAWSEGMENT* newSegment; + + if( moduleEdge ) + { + EDGE_MODULE* edge = static_cast( segment ); + assert( segment->GetParent()->Type() == PCB_MODULE_T ); + newSegment = new EDGE_MODULE( *edge ); + edge->SetLocalCoord(); + } + else + { + newSegment = new DRAWSEGMENT( *segment ); + } + newSegment->ClearSelected(); newSegment->SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) ); newSegment->SetEnd( wxPoint( seg.B.x, seg.B.y ) ); - getModel()->Add( newSegment ); + if( moduleEdge ) + { + static_cast( newSegment )->SetLocalCoord(); + getModel()->m_Modules->Add( newSegment ); + } + else + { + getModel()->Add( newSegment ); + } + getView()->Add( newSegment ); } }