2011-12-29 20:11:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-29 20:11:42 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file editedge.cpp
|
|
|
|
* @brief Edit segments and edges of PCB.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_drawsegment.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC );
|
2011-09-07 19:41:04 +00:00
|
|
|
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase );
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
static wxPoint s_InitialPosition; // Initial cursor position.
|
|
|
|
static wxPoint s_LastPosition; // Current cursor position.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Start move of a graphic element type DRAWSEGMENT
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( drawitem == NULL )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
drawitem->Draw( m_canvas, DC, GR_XOR );
|
2011-12-21 13:42:02 +00:00
|
|
|
drawitem->SetFlags( IS_MOVED );
|
2013-08-03 05:15:23 +00:00
|
|
|
s_InitialPosition = s_LastPosition = GetCrossHairPosition();
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( drawitem );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( Move_Segment, Abort_EditEdge );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( drawitem );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*
|
2009-11-14 22:15:22 +00:00
|
|
|
* Place graphic element of type DRAWSEGMENT.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( drawitem == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
drawitem->ClearFlags();
|
2009-08-06 15:42:09 +00:00
|
|
|
SaveCopyInUndoList(drawitem, UR_MOVED, s_LastPosition - s_InitialPosition);
|
2011-12-22 13:28:11 +00:00
|
|
|
drawitem->Draw( m_canvas, DC, GR_OR );
|
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/*
|
|
|
|
* Redraw segment during cursor movement.
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
DRAWSEGMENT* segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
if( segment == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2011-12-14 04:29:25 +00:00
|
|
|
segment->Draw( aPanel, aDC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxPoint delta;
|
2013-08-03 05:15:23 +00:00
|
|
|
delta = aPanel->GetParent()->GetCrossHairPosition() - s_LastPosition;
|
2011-12-14 04:29:25 +00:00
|
|
|
|
|
|
|
segment->SetStart( segment->GetStart() + delta );
|
|
|
|
segment->SetEnd( segment->GetEnd() + delta );
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
s_LastPosition = aPanel->GetParent()->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
segment->Draw( aPanel, aDC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* PtStruct;
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions();
|
2015-02-02 08:06:39 +00:00
|
|
|
bool tmp = displ_opts->m_DisplayDrawItemsFill;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( Segment->IsNew() ) // Trace in progress.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
// Delete current segment.
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayDrawItemsFill = SKETCH;
|
2011-12-22 13:28:11 +00:00
|
|
|
Segment->Draw( m_canvas, DC, GR_XOR );
|
2008-11-24 06:53:43 +00:00
|
|
|
PtStruct = Segment->Back();
|
2007-10-03 15:21:13 +00:00
|
|
|
Segment ->DeleteStructure();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( PtStruct && (PtStruct->Type() == PCB_LINE_T ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment = (DRAWSEGMENT*) PtStruct;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayDrawItemsFill = tmp;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-12-21 13:42:02 +00:00
|
|
|
else if( Segment->GetFlags() == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
Segment->Draw( m_canvas, DC, GR_XOR );
|
2011-12-21 13:42:02 +00:00
|
|
|
Segment->ClearFlags();
|
2009-07-29 13:10:36 +00:00
|
|
|
SaveCopyInUndoList(Segment, UR_DELETED);
|
|
|
|
Segment->UnLink();
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( LAYER_ID aLayer )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( aLayer ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
DisplayError( this, _( "Copper layer global delete not allowed!" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wxString msg = wxString::Format(
|
|
|
|
_( "Delete everything on layer %s?" ),
|
|
|
|
GetChars( GetBoard()->GetLayerName( aLayer ) ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
return;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
PICKED_ITEMS_LIST pickList;
|
|
|
|
ITEM_PICKER picker( NULL, UR_DELETED );
|
|
|
|
BOARD_ITEM* PtNext;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
PtNext = item->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_DIMENSION_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2009-08-11 10:27:21 +00:00
|
|
|
if( item->GetLayer() == aLayer )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-06 15:42:09 +00:00
|
|
|
item->UnLink();
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetItem( item );
|
2009-11-14 22:15:22 +00:00
|
|
|
pickList.PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2009-11-14 22:15:22 +00:00
|
|
|
msg.Printf( wxT("Delete_Drawings_All_Layer() error: unknown type %d"),
|
|
|
|
item->Type() );
|
2009-08-11 10:27:21 +00:00
|
|
|
wxMessageBox( msg );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-06 15:42:09 +00:00
|
|
|
|
|
|
|
if( pickList.GetCount() )
|
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-11 10:27:21 +00:00
|
|
|
SaveCopyInUndoList(pickList, UR_DELETED);
|
2009-08-06 15:42:09 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Segment == NULL )
|
2011-02-13 17:53:48 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
aPanel->SetMouseCapture( NULL, NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2011-02-13 17:53:48 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
if( Segment->IsNew() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
aPanel->CallMouseCapture( DC, wxDefaultPosition, false );
|
2007-10-03 15:21:13 +00:00
|
|
|
Segment ->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint pos = aPanel->GetParent()->GetCrossHairPosition();
|
|
|
|
aPanel->GetParent()->SetCrossHairPosition( s_InitialPosition );
|
|
|
|
aPanel->CallMouseCapture( DC, wxDefaultPosition, true );
|
|
|
|
aPanel->GetParent()->SetCrossHairPosition( pos );
|
2011-12-21 13:42:02 +00:00
|
|
|
Segment->ClearFlags();
|
2013-08-03 05:15:23 +00:00
|
|
|
Segment->Draw( aPanel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2013-02-14 19:57:19 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2013-08-03 05:15:23 +00:00
|
|
|
aPanel->Refresh();
|
2013-02-14 19:57:19 +00:00
|
|
|
#endif
|
2013-08-03 05:15:23 +00:00
|
|
|
|
|
|
|
aPanel->SetMouseCapture( NULL, NULL );
|
|
|
|
( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Initialize the drawing of a segment of type other than trace.
|
|
|
|
*/
|
2012-05-22 17:51:18 +00:00
|
|
|
DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int s_large;
|
|
|
|
DRAWSEGMENT* DrawItem;
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
s_large = GetDesignSettings().m_DrawSegmentWidth;
|
2011-05-13 13:15:28 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( GetActiveLayer() == Edge_Cuts )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
s_large = GetDesignSettings().m_EdgeSegmentWidth;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( Segment == NULL ) // Create new trace.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
|
2011-12-21 13:42:02 +00:00
|
|
|
Segment->SetFlags( IS_NEW );
|
2014-03-21 10:17:47 +00:00
|
|
|
Segment->SetLayer( GetActiveLayer() );
|
2011-12-14 04:29:25 +00:00
|
|
|
Segment->SetWidth( s_large );
|
|
|
|
Segment->SetShape( shape );
|
|
|
|
Segment->SetAngle( 900 );
|
2013-08-03 05:15:23 +00:00
|
|
|
Segment->SetStart( GetCrossHairPosition() );
|
|
|
|
Segment->SetEnd( GetCrossHairPosition() );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( DrawSegment, Abort_EditEdge );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-11-15 14:12:53 +00:00
|
|
|
else /* The ending point ccordinate Segment->m_End was updated by he function
|
2011-09-07 19:41:04 +00:00
|
|
|
* DrawSegment() called on a move mouse event
|
2009-11-15 14:12:53 +00:00
|
|
|
* during the segment creation
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
if( Segment->GetStart() != Segment->GetEnd() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
if( Segment->GetShape() == S_SEGMENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
SaveCopyInUndoList( Segment, UR_NEW );
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( Segment );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-21 13:42:02 +00:00
|
|
|
Segment->ClearFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
Segment->Draw( m_canvas, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
DrawItem = Segment;
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
Segment->SetFlags( IS_NEW );
|
2007-08-23 04:28:46 +00:00
|
|
|
Segment->SetLayer( DrawItem->GetLayer() );
|
2011-12-14 04:29:25 +00:00
|
|
|
Segment->SetWidth( s_large );
|
|
|
|
Segment->SetShape( DrawItem->GetShape() );
|
|
|
|
Segment->SetType( DrawItem->GetType() );
|
|
|
|
Segment->SetAngle( DrawItem->GetAngle() );
|
|
|
|
Segment->SetStart( DrawItem->GetEnd() );
|
|
|
|
Segment->SetEnd( DrawItem->GetEnd() );
|
2011-12-22 13:28:11 +00:00
|
|
|
DrawSegment( m_canvas, DC, wxDefaultPosition, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
End_Edge( Segment, DC );
|
|
|
|
Segment = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-13 13:15:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return Segment;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
Segment->Draw( m_canvas, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Delete if segment length is zero.
|
|
|
|
if( Segment->GetStart() == Segment->GetEnd() )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
Segment->DeleteStructure();
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
Segment->ClearFlags();
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( Segment );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-11-14 22:15:22 +00:00
|
|
|
SaveCopyInUndoList( Segment, UR_NEW );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Redraw segment during cursor movement
|
|
|
|
*/
|
2011-09-07 19:41:04 +00:00
|
|
|
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
|
|
|
|
2015-02-02 08:06:39 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions();
|
|
|
|
bool tmp = displ_opts->m_DisplayDrawItemsFill;
|
|
|
|
|
|
|
|
displ_opts->m_DisplayDrawItemsFill = SKETCH;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
|
|
|
Segment->Draw( aPanel, aDC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-03-27 18:32:12 +00:00
|
|
|
if( g_Segments_45_Only && Segment->GetShape() == S_SEGMENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
wxPoint pt;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
CalculateSegmentEndPoint( aPanel->GetParent()->GetCrossHairPosition(),
|
2011-12-14 04:29:25 +00:00
|
|
|
Segment->GetStart().x, Segment->GetStart().y,
|
|
|
|
&pt.x, &pt.y );
|
|
|
|
Segment->SetEnd( pt );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-12-14 04:29:25 +00:00
|
|
|
else // here the angle is arbitrary
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
Segment->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
Segment->Draw( aPanel, aDC, GR_XOR );
|
2015-02-02 08:06:39 +00:00
|
|
|
displ_opts->m_DisplayDrawItemsFill = tmp;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|