2007-08-20 01:20:48 +00:00
|
|
|
/******************************************************/
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Edition of footprint edges */
|
2007-08-20 01:20:48 +00:00
|
|
|
/******************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* fichier edgemod.cpp */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Functions to edit graphic items used to draw footprint edges.
|
|
|
|
* Function to Arcs are not made (TODO..) 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 "gr_basic.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
#include "common.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"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Variables locales : */
|
2007-08-20 01:20:48 +00:00
|
|
|
int ArcValue = 900;
|
|
|
|
static wxPoint MoveVector; // Move vector for move edge
|
|
|
|
static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Function to initialise the move function params of a graphic item type DRAWSEGMENT
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
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;
|
|
|
|
CursorInitialPosition = GetScreen()->m_Curseur;
|
|
|
|
DrawPanel->ManageCurseur = Move_Segment;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( Edge );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, 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
|
|
|
/*********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*
|
2007-09-13 11:28:58 +00:00
|
|
|
* Function to place a graphic item type EDGE_MODULE currently moved
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
|
|
|
Edge->m_Start.x -= MoveVector.x;
|
|
|
|
Edge->m_Start.y -= MoveVector.y;
|
|
|
|
Edge->m_End.x -= MoveVector.x;
|
|
|
|
Edge->m_End.y -= MoveVector.y;
|
|
|
|
|
|
|
|
Edge->m_Start0.x -= MoveVector.x;
|
|
|
|
Edge->m_Start0.y -= MoveVector.y;
|
|
|
|
Edge->m_End0.x -= MoveVector.x;
|
|
|
|
Edge->m_End0.y -= MoveVector.y;
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( DrawPanel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Flags = 0;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* Module = (MODULE*) Edge->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->Set_Rectangle_Encadrement();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************/
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Move and redraw the current edited graphic item when mouse is moving */
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( panel, DC, GR_XOR, MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x);
|
|
|
|
MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y);
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( panel, DC, GR_XOR, MoveVector );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->Set_Rectangle_Encadrement();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowEdgeModule( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Redraw the current edited (moved) graphic item
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
// if( erase )
|
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End = screen->m_Curseur;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Mise a jour des coord relatives */
|
|
|
|
Edge->m_End0.x = Edge->m_End.x - Module->m_Pos.x;
|
|
|
|
Edge->m_End0.y = Edge->m_End.y - Module->m_Pos.y;
|
|
|
|
RotatePoint( (int*) &Edge->m_End0.x,
|
|
|
|
(int*) &Edge->m_End0.y, -Module->m_Orient );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
Edge->Draw( panel, DC, GR_XOR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->Set_Rectangle_Encadrement();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************/
|
2009-05-23 07:16:05 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* Edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Change the EDGE_MODULE Edge width,
|
|
|
|
* if Edge == NULL change the width of the entire footprint edges
|
|
|
|
* @param ModuleSegmentWidth (global) = new width
|
|
|
|
* @param Edge = edge to edit, or NULL
|
|
|
|
* @param DC = current Device Context
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
SaveCopyInUndoList( Module );
|
|
|
|
|
|
|
|
if( Edge == NULL )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings;
|
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;
|
|
|
|
Edge->m_Width = ModuleSegmentWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Edge->m_Width = ModuleSegmentWidth;
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
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-05-23 07:16:05 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Change the EDGE_MODULE Edge layer, (The new layer will be asked)
|
|
|
|
* if Edge == NULL change the layer of the entire footprint edges
|
|
|
|
* @param Edge = edge to edit, or NULL
|
|
|
|
* @param DC = current Device Context
|
|
|
|
*/
|
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 new_layer = SILKSCREEN_N_CMP;
|
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 */
|
2007-11-01 05:27:31 +00:00
|
|
|
new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( new_layer < 0 )
|
|
|
|
return;
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
if ( new_layer >= FIRST_COPPER_LAYER && new_layer <= LAST_COPPER_LAYER )
|
|
|
|
/* an edge is put on a copper layer, and it is very dangerous. a confirmation is requested */
|
|
|
|
{
|
|
|
|
if ( ! IsOK(this, _("The graphic item will be on a copper layer.It is very dangerous. Are you sure") ) )
|
|
|
|
return;
|
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
SaveCopyInUndoList( Module );
|
|
|
|
|
|
|
|
if( Edge == NULL )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
Edge = (EDGE_MODULE*)(BOARD_ITEM*) Module->m_Drawings;
|
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;
|
2007-08-23 04:28:46 +00:00
|
|
|
Edge->SetLayer( new_layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-08-23 04:28:46 +00:00
|
|
|
Edge->SetLayer( new_layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Edition of the edge items width
|
|
|
|
* Ask for a new width and init ModuleSegmentWidth.
|
|
|
|
* Change the width of EDGE_MODULE Edge if Edge != NULL
|
|
|
|
* @param Edge = edge to edit, or NULL
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @output ModuleSegmentWidth (global) = new width
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString buffer;
|
|
|
|
long ll;
|
|
|
|
|
|
|
|
buffer << ModuleSegmentWidth;
|
2008-09-22 16:03:12 +00:00
|
|
|
if( Get_Message( _( "New Width (1/10000\"):" ), _("Edge Width"), buffer, this ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( buffer.ToLong( &ll ) )
|
|
|
|
ModuleSegmentWidth = ll;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Incorrect number, no change" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( Edge )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* Module = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
|
|
|
Edge->m_Width = ModuleSegmentWidth;
|
|
|
|
Module->DrawEdgesOnly( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
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-05-23 07:16:05 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************************/
|
2009-05-23 07:16:05 +00:00
|
|
|
/** Function Delete_Edge_Module
|
|
|
|
* delete EDGE_MODULE Edge
|
|
|
|
* @param Edge = edge to delete
|
2007-09-13 11:28:58 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge == NULL )
|
|
|
|
return;
|
2008-12-04 04:28:11 +00:00
|
|
|
if( Edge->Type() != TYPE_EDGE_MODULE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +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
|
|
|
|
|
|
|
/* suppression d'un segment */
|
2007-10-03 15:21:13 +00:00
|
|
|
Edge ->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Exit_EditEdge_Module( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************************/
|
2007-09-13 11:28:58 +00:00
|
|
|
/* abort function in moving edge.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDGE_MODULE* Edge = (EDGE_MODULE*) Panel->GetScreen()->GetCurItem();
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( Edge && (Edge->Type() == TYPE_EDGE_MODULE) ) /* error si non */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( Edge->m_Flags & IS_NEW ) /* effacement du nouveau contour */
|
|
|
|
{
|
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 );
|
2007-10-03 15:21:13 +00:00
|
|
|
Edge ->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
Panel->GetScreen()->SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
|
|
|
|
wxDC* DC, int type_edge )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Create a new edge item (line, arc ..).
|
|
|
|
* @param Edge = if NULL: create new edge else terminate edge and create a new edge
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param type_edge = S_SEGMENT,S_ARC ..
|
|
|
|
* @return the new created edge.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
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
|
|
|
{
|
2008-12-06 08:21:54 +00:00
|
|
|
SaveCopyInUndoList( module );
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/* Mise a jour des caracteristiques du segment ou de l'arc */
|
|
|
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Width = ModuleSegmentWidth;
|
2008-12-06 08:21:54 +00:00
|
|
|
Edge->SetLayer( module->GetLayer() );
|
|
|
|
|
|
|
|
if( module->GetLayer() == CMP_N )
|
2007-08-23 04:28:46 +00:00
|
|
|
Edge->SetLayer( SILKSCREEN_N_CMP );
|
2008-12-06 08:21:54 +00:00
|
|
|
if( module->GetLayer() == COPPER_LAYER_N )
|
2007-08-23 04:28:46 +00:00
|
|
|
Edge->SetLayer( SILKSCREEN_N_CU );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Initialise the starting point of the new segment or arc */
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Start = GetScreen()->m_Curseur;
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Initialise the ending point of the new segment or arc */
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End = Edge->m_Start;
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Initialise the relative coordinates */
|
2008-12-06 08:21:54 +00:00
|
|
|
Edge->m_Start0.x = Edge->m_Start.x - module->m_Pos.x;
|
|
|
|
Edge->m_Start0.y = Edge->m_Start.y - module->m_Pos.y;
|
|
|
|
|
|
|
|
RotatePoint( (int*) &Edge->m_Start0.x,
|
|
|
|
(int*) &Edge->m_Start0.y, -module->m_Orient );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End0 = Edge->m_Start0;
|
2008-12-06 08:21:54 +00:00
|
|
|
module->Set_Rectangle_Encadrement();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = ShowEdgeModule;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge_Module;
|
|
|
|
}
|
2008-12-06 08:21:54 +00:00
|
|
|
|
|
|
|
/* trace en cours : les coord du point d'arrivee ont ete mises
|
|
|
|
* a jour par la routine Montre_Position_New_Edge_Module
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
|
|
|
// insert _after_ Edge, which is the same as inserting _before_ Edge->Next()
|
|
|
|
module->m_Drawings.Insert( newedge, Edge->Next() );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_Flags = 0;
|
|
|
|
Edge = newedge;
|
|
|
|
|
|
|
|
Edge->m_Flags = IS_NEW;
|
|
|
|
Edge->m_Width = ModuleSegmentWidth;
|
|
|
|
Edge->m_Start = GetScreen()->m_Curseur;
|
|
|
|
Edge->m_End = Edge->m_Start;
|
|
|
|
|
|
|
|
/* Mise a jour des coord relatives */
|
2008-12-06 08:21:54 +00:00
|
|
|
Edge->m_Start0.x = Edge->m_Start.x - module->m_Pos.x;
|
|
|
|
Edge->m_Start0.y = Edge->m_Start.y - module->m_Pos.y;
|
|
|
|
|
|
|
|
RotatePoint( (int*) &Edge->m_Start0.x,
|
|
|
|
(int*) &Edge->m_Start0.y, -module->m_Orient );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Edge->m_End0 = Edge->m_Start0;
|
|
|
|
|
2008-12-06 08:21:54 +00:00
|
|
|
module->Set_Rectangle_Encadrement();
|
|
|
|
module->m_LastEdit_Time = time( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayError( this, wxT( "Begin_Edge() error" ) );
|
|
|
|
}
|
|
|
|
return Edge;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Terminate a move or create edge function
|
|
|
|
*/
|
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
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* If last segment length is 0: deletion */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Edge )
|
|
|
|
{
|
|
|
|
if( (Edge->m_Start.x == Edge->m_End.x)
|
|
|
|
&& (Edge->m_Start.y == Edge->m_End.y) )
|
|
|
|
{
|
2007-10-03 15:21:13 +00:00
|
|
|
Edge ->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Edge->m_Flags = 0;
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|