2011-02-13 17:53:48 +00:00
|
|
|
/*******************************/
|
|
|
|
/* Footprint outlines editing. */
|
|
|
|
/*******************************/
|
2009-11-14 22:15:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions to edit graphic items used to draw footprint edges.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
int ArcValue = 900;
|
|
|
|
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
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( DrawPanel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Flags |= IS_MOVED;
|
|
|
|
MoveVector.x = MoveVector.y = 0;
|
2011-02-11 20:48:13 +00:00
|
|
|
CursorInitialPosition = GetScreen()->GetCrossHairPosition();
|
2011-02-13 17:53:48 +00:00
|
|
|
DrawPanel->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( Edge );
|
2011-09-07 19:41:04 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* Edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
Edge->m_Start -= MoveVector;
|
|
|
|
Edge->m_End -= MoveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
Edge->m_Start0 -= MoveVector;
|
|
|
|
Edge->m_End0 -= MoveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
Edge->m_Flags = 0;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* Module = (MODULE*) Edge->GetParent();
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
2010-07-20 18:11:34 +00:00
|
|
|
DrawPanel->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();
|
2007-08-20 01:20:48 +00:00
|
|
|
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +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
|
|
|
{
|
2011-02-03 19:27:28 +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
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
MoveVector = -(screen->GetCrossHairPosition() - CursorInitialPosition);
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
Edge->Draw( aPanel, aDC, GR_XOR, MoveVector );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-09-07 19:41:04 +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();
|
2007-08-20 01:20:48 +00:00
|
|
|
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-11-24 06:53:43 +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
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
Edge->Draw( aPanel, aDC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
Edge->m_End = screen->GetCrossHairPosition();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update relative coordinate. */
|
2009-08-03 18:54:48 +00:00
|
|
|
Edge->m_End0 = Edge->m_End - Module->m_Pos;
|
|
|
|
RotatePoint( &Edge->m_End0, -Module->m_Orient );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
Edge->Draw( aPanel, aDC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-09-07 19:41:04 +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
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* Module = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( Module, UR_MODEDIT );
|
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
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
aEdge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
for( ; aEdge != NULL; aEdge = aEdge->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
if( aEdge->Type() != TYPE_EDGE_MODULE )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
aEdge->m_Width = g_ModuleSegmentWidth;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
aEdge->m_Width = g_ModuleSegmentWidth;
|
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();
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* Edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* Module = GetBoard()->m_Modules;
|
2009-12-21 17:56:25 +00:00
|
|
|
int new_layer = SILKSCREEN_N_FRONT;
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
if( Edge != NULL )
|
|
|
|
new_layer = Edge->GetLayer();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
/* Ask for the new layer */
|
2011-08-26 17:01:17 +00:00
|
|
|
new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( new_layer < 0 )
|
|
|
|
return;
|
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( IsValidCopperLayerIndex( new_layer ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
/* an edge is put on a copper layer, and it is very dangerous. a
|
|
|
|
*confirmation is requested */
|
|
|
|
if( !IsOK( this,
|
2011-02-11 20:48:13 +00:00
|
|
|
_( "The graphic item will be on a copper layer. It is very dangerous. Are you sure?" ) ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( Module, UR_MODEDIT );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Edge == NULL )
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; Edge != NULL; Edge = Edge->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( Edge->Type() != TYPE_EDGE_MODULE )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
Edge->SetLayer( new_layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
Edge->SetLayer( new_layer );
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString buffer;
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth,
|
|
|
|
GetScreen()->GetInternalUnits() );
|
2010-07-20 18:11:34 +00:00
|
|
|
wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2011-08-26 17:01:17 +00:00
|
|
|
return; // canceled by user
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
buffer = dlg.GetValue( );
|
2011-02-11 20:48:13 +00:00
|
|
|
g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer,
|
|
|
|
GetScreen()->GetInternalUnits() );
|
2010-07-20 18:11:34 +00:00
|
|
|
|
|
|
|
if( aEdge )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* Module = GetBoard()->m_Modules;
|
2010-07-20 18:11:34 +00:00
|
|
|
aEdge->m_Width = g_ModuleSegmentWidth;
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
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
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* Edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( Edge->Type() != TYPE_EDGE_MODULE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-08-26 17:01:17 +00:00
|
|
|
DisplayError( this, wxT( "StructType error: TYPE_EDGE_MODULE expected" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* Module = (MODULE*) Edge->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Delete segment. */
|
|
|
|
Edge->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
2011-09-07 19:41:04 +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
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
Panel->SetMouseCapture( NULL, NULL );
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( Edge && ( Edge->Type() == TYPE_EDGE_MODULE ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
if( Edge->IsNew() ) // On aborting, delete new outline.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* Module = (MODULE*) Edge->GetParent();
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( Panel, DC, GR_XOR, MoveVector );
|
2009-11-14 22:15:22 +00:00
|
|
|
Edge->DeleteStructure();
|
2011-09-07 19:41:04 +00:00
|
|
|
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
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( Panel, DC, GR_XOR, MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Flags = 0;
|
2008-04-01 05:21:50 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
|
|
|
|
wxDC* DC,
|
|
|
|
int 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
|
|
|
int angle = 0;
|
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
if( module == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
if( Edge == NULL ) /* Start a new edge item */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( module, UR_MODEDIT );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
|
|
|
Edge = new EDGE_MODULE( module );
|
2007-08-20 01:20:48 +00:00
|
|
|
MoveVector.x = MoveVector.y = 0;
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Add the new item to the Drawings list head*/
|
2008-12-06 08:21:54 +00:00
|
|
|
module->m_Drawings.PushFront( Edge );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update characteristics of the segment or arc. */
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Flags = IS_NEW;
|
|
|
|
Edge->m_Angle = angle;
|
|
|
|
Edge->m_Shape = type_edge;
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge->m_Shape == S_ARC )
|
|
|
|
Edge->m_Angle = ArcValue;
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
Edge->m_Width = g_ModuleSegmentWidth;
|
2008-12-06 08:21:54 +00:00
|
|
|
Edge->SetLayer( module->GetLayer() );
|
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( module->GetLayer() == LAYER_N_FRONT )
|
2009-12-21 17:56:25 +00:00
|
|
|
Edge->SetLayer( SILKSCREEN_N_FRONT );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( module->GetLayer() == LAYER_N_BACK )
|
2009-12-21 17:56:25 +00:00
|
|
|
Edge->SetLayer( SILKSCREEN_N_BACK );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/* Initialize the starting point of the new segment or arc */
|
2011-02-11 20:48:13 +00:00
|
|
|
Edge->m_Start = GetScreen()->GetCrossHairPosition();
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/* Initialize the ending point of the new segment or arc */
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End = Edge->m_Start;
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/* Initialize the relative coordinates */
|
2009-08-03 18:54:48 +00:00
|
|
|
Edge->m_Start0 = Edge->m_Start - module->m_Pos;
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
RotatePoint( &Edge->m_Start0, -module->m_Orient );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End0 = Edge->m_Start0;
|
2011-09-07 19:41:04 +00:00
|
|
|
module->CalculateBoundingBox();
|
2011-02-13 17:53:48 +00:00
|
|
|
DrawPanel->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 )
|
|
|
|
{
|
2008-12-06 08:21:54 +00:00
|
|
|
if( Edge->m_Start0 != Edge->m_End0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( DrawPanel, DC, GR_OR );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
|
|
|
EDGE_MODULE* newedge = new EDGE_MODULE( module );
|
2007-08-20 01:20:48 +00:00
|
|
|
newedge->Copy( Edge );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
// insert _after_ Edge, which is the same as inserting before Edge->Next()
|
2008-12-06 08:21:54 +00:00
|
|
|
module->m_Drawings.Insert( newedge, Edge->Next() );
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Flags = 0;
|
2009-08-03 18:54:48 +00:00
|
|
|
|
|
|
|
Edge = newedge; // point now new item
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
Edge->m_Flags = IS_NEW;
|
2010-07-20 18:11:34 +00:00
|
|
|
Edge->m_Width = g_ModuleSegmentWidth;
|
2011-02-11 20:48:13 +00:00
|
|
|
Edge->m_Start = GetScreen()->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End = Edge->m_Start;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update relative coordinate. */
|
2009-08-03 18:54:48 +00:00
|
|
|
Edge->m_Start0 = Edge->m_Start - module->m_Pos;
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
RotatePoint( &Edge->m_Start0, -module->m_Orient );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End0 = Edge->m_Start0;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
module->CalculateBoundingBox();
|
2008-12-06 08:21:54 +00:00
|
|
|
module->m_LastEdit_Time = time( NULL );
|
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
|
|
|
{
|
2009-08-03 18:54:48 +00:00
|
|
|
wxMessageBox( 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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return Edge;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* 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
|
|
|
|
|
|
|
if( Edge )
|
|
|
|
{
|
2009-08-03 18:54:48 +00:00
|
|
|
Edge->m_Flags = 0;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2009-08-03 18:54:48 +00:00
|
|
|
/* If last segment length is 0: remove it */
|
|
|
|
if( Edge->m_Start == Edge->m_End )
|
2009-11-14 22:15:22 +00:00
|
|
|
Edge->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|