2011-12-29 20:11:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-09-11 15:30:21 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2013 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
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
|
|
|
|
/**
|
2011-12-29 20:11:42 +00:00
|
|
|
* @file edgemod.cpp:
|
|
|
|
* @brief Functions to edit graphic items used to draw footprint edges.
|
2009-11-14 22:15:22 +00:00
|
|
|
*
|
|
|
|
* @todo - Arc functions not compete but menus are ready to use.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2018-03-12 22:45:17 +00:00
|
|
|
#include <dialog_text_entry.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
2011-08-26 17:01:17 +00:00
|
|
|
bool erase );
|
2011-02-13 17:53:48 +00:00
|
|
|
static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2011-08-26 17:01:17 +00:00
|
|
|
static void ShowCurrentOutlineWhileMoving( 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
|
|
|
static double ArcValue = 900;
|
2007-08-20 01:20:48 +00:00
|
|
|
static wxPoint MoveVector; // Move vector for move edge
|
2011-08-26 17:01:17 +00:00
|
|
|
static wxPoint CursorInitialPosition; // Mouse cursor initial position for move command
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* aEdge, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->Draw( m_canvas, DC, GR_XOR );
|
|
|
|
aEdge->SetFlags( IS_MOVED );
|
2007-08-20 01:20:48 +00:00
|
|
|
MoveVector.x = MoveVector.y = 0;
|
2013-08-03 05:15:23 +00:00
|
|
|
CursorInitialPosition = GetCrossHairPosition();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline );
|
2012-02-02 17:45:37 +00:00
|
|
|
SetCurItem( aEdge );
|
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
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* aEdge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
if( aEdge == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2018-07-07 11:04:01 +00:00
|
|
|
aEdge->Move( -MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
aEdge->ClearFlags();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-14 04:29:25 +00:00
|
|
|
|
|
|
|
MODULE* module = (MODULE*) aEdge->GetParent();
|
|
|
|
module->CalculateBoundingBox();
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
/* Redraw the current moved graphic item when mouse is moving
|
|
|
|
* Use this function to show an existing outline, in move command
|
|
|
|
*/
|
2011-08-26 17:01:17 +00:00
|
|
|
static void ShowCurrentOutlineWhileMoving( 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
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2012-02-02 17:45:37 +00:00
|
|
|
EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( edge == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
MODULE* module = (MODULE*) edge->GetParent();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
MoveVector = -(aPanel->GetParent()->GetCrossHairPosition() - CursorInitialPosition);
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
module->CalculateBoundingBox();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
/* Redraw the current graphic item during its creation
|
|
|
|
* Use this function to show a new outline, in begin command
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-02-13 17:53:48 +00:00
|
|
|
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
2011-08-26 17:01:17 +00:00
|
|
|
bool aErase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2012-02-02 17:45:37 +00:00
|
|
|
EDGE_MODULE* edge = (EDGE_MODULE*) screen->GetCurItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( edge == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
MODULE* module = (MODULE*) edge->GetParent();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
// if( erase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->Draw( aPanel, aDC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
edge->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Update relative coordinate.
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->SetEnd0( edge->GetEnd() - module->GetPosition() );
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
wxPoint pt( edge->GetEnd0() );
|
2011-12-14 04:29:25 +00:00
|
|
|
|
|
|
|
RotatePoint( &pt, -module->GetOrientation() );
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->SetEnd0( pt );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->Draw( aPanel, aDC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
module->CalculateBoundingBox();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-02 07:23:00 +00:00
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( module, UR_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( aEdge == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( BOARD_ITEM *item = module->GraphicalItemsList(); item; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
aEdge = dyn_cast<EDGE_MODULE*>( item );
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
if( aEdge )
|
2018-04-28 15:22:25 +00:00
|
|
|
aEdge->SetWidth( GetDesignSettings().GetLineThickness( aEdge->GetLayer() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
aEdge->SetWidth( GetDesignSettings().GetLineThickness( aEdge->GetLayer() ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2012-02-02 07:23:00 +00:00
|
|
|
module->CalculateBoundingBox();
|
2012-09-05 12:13:33 +00:00
|
|
|
module->SetLastEditTime();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-09-11 15:30:21 +00:00
|
|
|
// note: if aEdge == NULL, all outline segments will be modified
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = F_SilkS;
|
2014-06-24 16:17:18 +00:00
|
|
|
bool modified = false;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2012-02-02 07:23:00 +00:00
|
|
|
if( aEdge )
|
2013-09-11 15:30:21 +00:00
|
|
|
layer = aEdge->GetLayer();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Ask for the new layer
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID new_layer = SelectLayer( layer, Edge_Cuts );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
if( layer < 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2013-04-09 16:00:46 +00:00
|
|
|
if( IsCopperLayer( new_layer ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2015-01-07 19:07:15 +00:00
|
|
|
// an edge is put on a copper layer, and it is very dangerous.
|
|
|
|
// A confirmation is requested
|
2009-11-14 22:15:22 +00:00
|
|
|
if( !IsOK( this,
|
2015-01-07 19:07:15 +00:00
|
|
|
_( "The graphic item will be on a copper layer.\n"
|
|
|
|
"This is very dangerous. Are you sure?" ) ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !aEdge )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2017-04-25 09:06:24 +00:00
|
|
|
for( BOARD_ITEM *item = module->GraphicalItemsList() ; item != NULL;
|
2014-04-30 19:16:22 +00:00
|
|
|
item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-06-06 09:44:21 +00:00
|
|
|
aEdge = dyn_cast<EDGE_MODULE*>( item );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
if( aEdge && (aEdge->GetLayer() != new_layer) )
|
2013-09-11 15:30:21 +00:00
|
|
|
{
|
|
|
|
if( ! modified ) // save only once
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( module, UR_CHANGED );
|
2013-09-11 15:30:21 +00:00
|
|
|
aEdge->SetLayer( new_layer );
|
|
|
|
modified = true;
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-11 15:30:21 +00:00
|
|
|
else if( aEdge->GetLayer() != new_layer )
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( module, UR_CHANGED );
|
2012-02-02 07:23:00 +00:00
|
|
|
aEdge->SetLayer( new_layer );
|
2013-09-11 15:30:21 +00:00
|
|
|
modified = true;
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-09-11 15:30:21 +00:00
|
|
|
if( modified )
|
|
|
|
{
|
|
|
|
module->CalculateBoundingBox();
|
|
|
|
module->SetLastEditTime();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* aEdge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge->Type() != PCB_MODULE_EDGE_T )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "StructType error: PCB_MODULE_EDGE_T expected" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
MODULE* module = (MODULE*) aEdge->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Delete segment.
|
|
|
|
aEdge->DeleteStructure();
|
2012-09-05 12:13:33 +00:00
|
|
|
module->SetLastEditTime();
|
2012-02-02 17:45:37 +00:00
|
|
|
module->CalculateBoundingBox();
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
/* abort function in moving outline.
|
2009-11-14 22:15:22 +00:00
|
|
|
*/
|
2011-02-13 17:53:48 +00:00
|
|
|
static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
EDGE_MODULE* edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
Panel->SetMouseCapture( NULL, NULL );
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( edge && ( edge->Type() == PCB_MODULE_EDGE_T ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
if( edge->IsNew() ) // On aborting, delete new outline.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
MODULE* module = (MODULE*) edge->GetParent();
|
|
|
|
edge->Draw( Panel, DC, GR_XOR, MoveVector );
|
|
|
|
edge->DeleteStructure();
|
|
|
|
module->CalculateBoundingBox();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-13 17:53:48 +00:00
|
|
|
else // On aborting, move existing outline to its initial position.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
edge->Draw( Panel, DC, GR_XOR, MoveVector );
|
|
|
|
edge->ClearFlags();
|
|
|
|
edge->Draw( Panel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Panel->GetScreen()->SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge,
|
2011-08-26 17:01:17 +00:00
|
|
|
wxDC* DC,
|
2012-05-22 17:51:18 +00:00
|
|
|
STROKE_T type_edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
if( module == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge == NULL ) // Start a new edge item
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2016-05-25 09:52:43 +00:00
|
|
|
SaveCopyInUndoList( module, UR_CHANGED );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge = new EDGE_MODULE( module );
|
2007-08-20 01:20:48 +00:00
|
|
|
MoveVector.x = MoveVector.y = 0;
|
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Add the new item to the Drawings list head
|
2017-04-25 09:06:24 +00:00
|
|
|
module->GraphicalItemsList().PushFront( aEdge );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Update characteristics of the segment or arc.
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetFlags( IS_NEW );
|
2013-05-01 17:32:36 +00:00
|
|
|
aEdge->SetAngle( 0 );
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetShape( type_edge );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge->GetShape() == S_ARC )
|
|
|
|
aEdge->SetAngle( ArcValue );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
aEdge->SetWidth( GetDesignSettings().GetLineThickness( GetActiveLayer() ) );
|
2015-01-07 19:07:15 +00:00
|
|
|
aEdge->SetLayer( GetActiveLayer() );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Initialize the starting point of the new segment or arc
|
2013-08-03 05:15:23 +00:00
|
|
|
aEdge->SetStart( GetCrossHairPosition() );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Initialize the ending point of the new segment or arc
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetEnd( aEdge->GetStart() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
// Initialize the relative coordinates
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
RotatePoint( &aEdge->m_Start0, -module->GetOrientation() );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->m_End0 = aEdge->m_Start0;
|
2011-09-07 19:41:04 +00:00
|
|
|
module->CalculateBoundingBox();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( ShowNewEdgeModule, Abort_Move_ModuleOutline );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-11-15 14:12:53 +00:00
|
|
|
/* Segment creation in progress.
|
2011-02-13 17:53:48 +00:00
|
|
|
* The ending coordinate is updated by the function
|
|
|
|
* ShowNewEdgeModule() called on move mouse event
|
2011-08-26 17:01:17 +00:00
|
|
|
* during the segment creation
|
2008-12-06 08:21:54 +00:00
|
|
|
*/
|
|
|
|
else
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( type_edge == S_SEGMENT )
|
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge->m_Start0 != aEdge->m_End0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->Draw( m_canvas, DC, GR_OR );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
EDGE_MODULE* newedge = new EDGE_MODULE( *aEdge );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// insert _after_ aEdge, which is the same as inserting before aEdge->Next()
|
2017-04-25 09:06:24 +00:00
|
|
|
module->GraphicalItemsList().Insert( newedge, aEdge->Next() );
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->ClearFlags();
|
2009-08-03 18:54:48 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge = newedge; // point now new item
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetFlags( IS_NEW );
|
2018-04-28 15:22:25 +00:00
|
|
|
aEdge->SetWidth( GetDesignSettings().GetLineThickness( aEdge->GetLayer() ) );
|
2013-08-03 05:15:23 +00:00
|
|
|
aEdge->SetStart( GetCrossHairPosition() );
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetEnd( aEdge->GetStart() );
|
2011-12-14 04:29:25 +00:00
|
|
|
|
|
|
|
// Update relative coordinate.
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetStart0( aEdge->GetStart() - module->GetPosition() );
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
wxPoint pt( aEdge->GetStart0() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
RotatePoint( &pt, -module->GetOrientation() );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetStart0( pt );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->SetEnd0( aEdge->GetStart0() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
module->CalculateBoundingBox();
|
2012-09-05 12:13:33 +00:00
|
|
|
module->SetLastEditTime();
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2019-01-02 04:43:13 +00:00
|
|
|
wxLogDebug( wxT( "Begin_Edge() error" ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
return aEdge;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* aEdge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
if( aEdge )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
aEdge->ClearFlags();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// If last segment length is 0: remove it
|
|
|
|
if( aEdge->GetStart() == aEdge->GetEnd() )
|
|
|
|
aEdge->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
module->CalculateBoundingBox();
|
2012-09-05 12:13:33 +00:00
|
|
|
module->SetLastEditTime();
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|