2007-08-20 01:20:48 +00:00
|
|
|
/******************************************************/
|
|
|
|
/* Edition des contours du pcb: Routines */
|
|
|
|
/* d'effacement et d'edition de segments et contours */
|
|
|
|
/* du type PCB, draw, edgePCB */
|
|
|
|
/******************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.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 Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
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
|
|
|
static wxPoint cursor_pos; // position originelle du curseur souris (fct deplacement)
|
|
|
|
static wxPoint cursor_pos0; // position courante du curseur souris
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Routine de preparation du deplacement d'un element graphique type DRAWSEGMENT
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( drawitem == NULL )
|
|
|
|
return;
|
2008-04-01 06:32:48 +00:00
|
|
|
drawitem->Draw( DrawPanel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
drawitem->m_Flags |= IS_MOVED;
|
|
|
|
cursor_pos = cursor_pos0 = GetScreen()->m_Curseur;
|
2009-04-17 08:51:02 +00:00
|
|
|
drawitem->DisplayInfo( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = Move_Segment;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( drawitem );
|
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_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, 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-08-20 01:20:48 +00:00
|
|
|
* Routine de placement de l'element graphique type DRAWSEGMENT en cours de deplacement
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( drawitem == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-04-01 06:32:48 +00:00
|
|
|
drawitem->Draw( DrawPanel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
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();
|
|
|
|
drawitem->m_Flags = 0;
|
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
|
|
|
/************************************************************************/
|
|
|
|
/* redessin du contour du Segment Edge lors des deplacements de la souris */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DRAWSEGMENT* Segment = (DRAWSEGMENT*)
|
|
|
|
panel->GetScreen()->GetCurItem();
|
|
|
|
int t_fill = DisplayOpt.DisplayDrawItems;
|
|
|
|
|
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DisplayOpt.DisplayDrawItems = SKETCH;
|
|
|
|
|
|
|
|
/* efface ancienne position */
|
|
|
|
if( erase )
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxPoint delta;
|
|
|
|
delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x;
|
|
|
|
delta.y = panel->GetScreen()->m_Curseur.y - cursor_pos.y;
|
|
|
|
Segment->m_Start.x += delta.x;
|
|
|
|
Segment->m_Start.y += delta.y;
|
|
|
|
Segment->m_End.x += delta.x;
|
|
|
|
Segment->m_End.y += delta.y;
|
|
|
|
cursor_pos = panel->GetScreen()->m_Curseur;
|
|
|
|
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayOpt.DisplayDrawItems = t_fill;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* PtStruct;
|
|
|
|
int track_fill_copy = DisplayOpt.DisplayDrawItems;
|
|
|
|
|
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Segment->m_Flags & IS_NEW ) // Trace en cours, on peut effacer le dernier segment
|
|
|
|
{
|
|
|
|
/* effacement du segment en cours de trace */
|
|
|
|
DisplayOpt.DisplayDrawItems = SKETCH;
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( DrawPanel, DC, GR_XOR );
|
2008-11-24 06:53:43 +00:00
|
|
|
PtStruct = Segment->Back();
|
2007-10-03 15:21:13 +00:00
|
|
|
Segment ->DeleteStructure();
|
2008-12-04 04:28:11 +00:00
|
|
|
if( PtStruct && (PtStruct->Type() == TYPE_DRAWSEGMENT ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment = (DRAWSEGMENT*) PtStruct;
|
|
|
|
DisplayOpt.DisplayDrawItems = track_fill_copy;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( DrawPanel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment->m_Flags = 0;
|
2007-10-03 15:21:13 +00:00
|
|
|
Segment ->DeleteStructure();
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int layer = Segment->GetLayer();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
if( layer <= LAST_COPPER_LAYER )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Segment->m_Flags )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Segment is being edited" ), 10 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
wxString msg = _( "Delete Layer " ) + GetBoard()->GetLayerName( layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
return;
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
BOARD_ITEM* PtNext;
|
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
|
|
|
{
|
|
|
|
GetScreen()->SetModify();
|
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
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_COTATION:
|
2008-04-01 05:21:50 +00:00
|
|
|
if( item->GetLayer() == layer )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
item->Draw( DrawPanel, DC, GR_XOR );
|
|
|
|
item->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "Type Drawing Inconnu" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DRAWSEGMENT* Segment = (DRAWSEGMENT*) Panel->GetScreen()->GetCurItem();
|
|
|
|
|
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Segment->m_Flags & IS_NEW )
|
|
|
|
{
|
|
|
|
Panel->ManageCurseur( Panel, DC, FALSE );
|
2007-10-03 15:21:13 +00:00
|
|
|
Segment ->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxPoint pos = Panel->GetScreen()->m_Curseur;
|
|
|
|
Panel->GetScreen()->m_Curseur = cursor_pos0;
|
|
|
|
Panel->ManageCurseur( Panel, DC, TRUE );
|
|
|
|
Panel->GetScreen()->m_Curseur = pos;
|
|
|
|
Segment->m_Flags = 0;
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( Panel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
((WinEDA_PcbFrame*)Panel->m_Parent)->SetCurItem( 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
|
|
|
/**********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
|
|
|
|
int shape, 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
|
|
|
/* Routine d'initialisation du trace d'un segment de type autre que piste
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int s_large;
|
|
|
|
int angle = 0;
|
|
|
|
DRAWSEGMENT* DrawItem;
|
|
|
|
|
|
|
|
s_large = g_DesignSettings.m_DrawSegmentWidth;
|
2008-02-12 21:12:46 +00:00
|
|
|
if( ((PCB_SCREEN*)GetScreen())->m_Active_Layer == EDGE_N )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
s_large = g_DesignSettings.m_EdgeSegmentWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( shape == S_ARC )
|
|
|
|
angle = 900;
|
|
|
|
|
|
|
|
if( Segment == NULL ) /* debut reel du trace */
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment->m_Flags = IS_NEW;
|
2008-02-12 21:12:46 +00:00
|
|
|
Segment->SetLayer( ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment->m_Width = s_large;
|
|
|
|
Segment->m_Shape = shape;
|
|
|
|
Segment->m_Angle = 900;
|
|
|
|
Segment->m_Start = Segment->m_End = GetScreen()->m_Curseur;
|
|
|
|
DrawPanel->ManageCurseur = Montre_Position_NewSegment;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_EditEdge;
|
|
|
|
}
|
|
|
|
else /* trace en cours : les coord du point d'arrivee ont ete mises
|
|
|
|
* a jour par la routine Montre_Position_NewSegment*/
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( Segment->m_Start != Segment->m_End )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( Segment->m_Shape == S_SEGMENT )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( Segment );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
Segment->m_Flags = 0;
|
|
|
|
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( DrawPanel, 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
|
|
|
|
|
|
|
Segment->m_Flags = IS_NEW;
|
2007-08-23 04:28:46 +00:00
|
|
|
Segment->SetLayer( DrawItem->GetLayer() );
|
2007-08-20 01:20:48 +00:00
|
|
|
Segment->m_Width = s_large;
|
|
|
|
Segment->m_Shape = DrawItem->m_Shape;
|
|
|
|
Segment->m_Type = DrawItem->m_Type;
|
|
|
|
Segment->m_Angle = DrawItem->m_Angle;
|
|
|
|
Segment->m_Start = Segment->m_End = DrawItem->m_End;
|
|
|
|
Montre_Position_NewSegment( DrawPanel, DC, FALSE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
End_Edge( Segment, DC );
|
|
|
|
Segment = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Segment;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_PcbFrame::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;
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( DrawPanel, DC, GR_OR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Effacement si Longueur nulle */
|
|
|
|
if( (Segment->m_Start.x == Segment->m_End.x)
|
|
|
|
&& (Segment->m_Start.y == Segment->m_End.y) )
|
2007-10-03 15:21:13 +00:00
|
|
|
Segment ->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Segment->m_Flags = 0;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( Segment );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************/
|
|
|
|
/* redessin du contour du Segment Edge lors des deplacements de la souris */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DRAWSEGMENT* Segment = (DRAWSEGMENT*)
|
|
|
|
panel->GetScreen()->GetCurItem();
|
|
|
|
int t_fill = DisplayOpt.DisplayDrawItems;
|
|
|
|
|
|
|
|
if( Segment == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DisplayOpt.DisplayDrawItems = SKETCH;
|
|
|
|
|
|
|
|
/* efface ancienne position */
|
|
|
|
if( erase )
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) )
|
|
|
|
{
|
|
|
|
Calcule_Coord_Extremite_45( Segment->m_Start.x, Segment->m_Start.y,
|
|
|
|
&Segment->m_End.x, &Segment->m_End.y );
|
|
|
|
}
|
|
|
|
else /* ici l'angle d'inclinaison est quelconque */
|
|
|
|
{
|
|
|
|
Segment->m_End = panel->GetScreen()->m_Curseur;
|
|
|
|
}
|
|
|
|
|
2008-04-01 06:32:48 +00:00
|
|
|
Segment->Draw( panel, DC, GR_XOR );
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayOpt.DisplayDrawItems = t_fill;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|