Commit 5d5a50dd authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix a bug which crashes Eeschema (when a label is being created, and...

Eeschema: fix a bug which crashes Eeschema (when a label is being created, and its type is changed  by popup menu, for instance to a text, before it was put on schematic)
remove unused file and minor coding style fix
parent 2bea1c67
...@@ -223,8 +223,18 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) ...@@ -223,8 +223,18 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
m_canvas->CrossHairOff( &dc ); // Erase schematic cursor m_canvas->CrossHairOff( &dc ); // Erase schematic cursor
text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
screen->Remove( text ); // For an exiting item (i.e. already in list):
screen->Append( newtext ); // replace the existing item by the new text in list
for( SCH_ITEM* item = screen->GetDrawItems(); item != NULL; item = item->Next() )
{
if( item == text )
{
screen->Remove( text );
screen->Append( newtext );
break;
}
}
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
OnModify(); OnModify();
newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
...@@ -246,7 +256,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) ...@@ -246,7 +256,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
// So this is equivalent to delete text and add newtext // So this is equivalent to delete text and add newtext
// If text if being currently edited (i.e. moved) // If text if being currently edited (i.e. moved)
// we also save the initial copy of text, and prepare undo command for new text modifications. // we also save the initial copy of text, and prepare undo command for new text modifications.
// we must save it as modified text (if currently beeing edited), then deleted text, // we must save it as modified text,if it is currently edited, then save as deleted text,
// and replace text with newtext // and replace text with newtext
PICKED_ITEMS_LIST pickList; PICKED_ITEMS_LIST pickList;
ITEM_PICKER picker( text, UR_CHANGED ); ITEM_PICKER picker( text, UR_CHANGED );
......
...@@ -47,7 +47,7 @@ class CONNECTED_POINT ...@@ -47,7 +47,7 @@ class CONNECTED_POINT
{ {
private: private:
BOARD_CONNECTED_ITEM * m_item; // a link to the parent item (track, via or pad) BOARD_CONNECTED_ITEM * m_item; // a link to the parent item (track, via or pad)
wxPoint m_point; // the connection point (coordinate of this point) wxPoint m_point; // coordinates of this connected point
public: public:
// ctor to build a CONNECTED_POINT instance, when the parent is a track or via // ctor to build a CONNECTED_POINT instance, when the parent is a track or via
......
/****************************************************/
/* Edition des pistes */
/* Routines de duplication et deplacement de pistes */
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "autorout.h"
#include "drag.h"
#include "protos.h"
/* Routines externes */
static void Show_MoveTrack( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Exit_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC );
#if 0
/* Routines Locales */
static void Duplic_Track( COMMAND* Cmd );
static void Place_Dupl_Route( COMMAND* Cmd );
#endif
/* variables locales */
static wxPoint PosInit, LastPos;
static TRACK* NewTrack; /* Nouvelle piste creee ou piste deplacee */
static int NbPtNewTrack;
static int Old_HightLigth_NetCode;
static bool Old_HightLigt_Status;
/**************************************************************/
static void Exit_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
/***************************************************************/
/* routine d'annulation de la commande drag, copy ou move track si une piste est en cours
* de tracage, ou de sortie de l'application EDITRACK.
* Appel par la touche ESC
*/
{
TRACK* NextS;
int ii;
/* Effacement du trace en cours */
wxPoint oldpos = Panel->GetScreen()->m_Curseur;
Panel->GetScreen()->m_Curseur = PosInit;
Panel->ManageCurseur( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = oldpos;
g_HightLigt_Status = FALSE;
( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
if( NewTrack )
{
if( NewTrack->m_Flags & IS_NEW )
{
for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS )
{
if( NewTrack == NULL )
break;
NextS = (TRACK*) NewTrack->Pnext;
delete NewTrack;
}
}
else /* Move : remise en ancienne position */
{
TRACK* Track = NewTrack;
int dx = LastPos.x - PosInit.x;
int dy = LastPos.y - PosInit.y;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
{
if( Track == NULL )
break;
Track->m_Start.x -= dx;
Track->m_Start.y -= dy;
Track->m_End.x -= dx;
Track->m_End.y -= dy;
Track->m_Flags = 0;
}
Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR );
}
NewTrack = NULL;
}
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
Panel->SetCurItem( NULL );
// Panel->m_Parent->EraseMsgBox(); SeCurItem() does this
/* Annulation deplacement et Redessin des segments dragges */
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{
TRACK* Track = pt_drag->m_Segm;
pt_drag->SetInitialValues();
Track->SetState( EDIT, OFF );
Track->ClearFlags();
Track->Draw( Panel, DC, GR_OR );
}
g_HightLigth_NetCode = Old_HightLigth_NetCode;
g_HightLigt_Status = Old_HightLigt_Status;
if( g_HightLigt_Status )
( (WinEDA_PcbFrame*) Panel->m_Parent )->DrawHightLight( DC, g_HightLigth_NetCode );
EraseDragListe();
}
/*************************************************************************/
static void Show_MoveTrack( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************************/
/* redessin du contour de la piste lors des deplacements de la souris */
{
int ii, dx, dy;
TRACK* Track;
BASE_SCREEN* screen = panel->GetScreen();
int track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
DisplayOpt.DisplayPcbTrackFill = SKETCH;
erase = TRUE;
/* efface ancienne position si elle a ete deja dessinee */
if( erase )
{
if( NewTrack )
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
}
/* mise a jour des coordonnees des segments de la piste */
wxPoint Pos = screen->m_Curseur;
dx = Pos.x - LastPos.x;
dy = Pos.y - LastPos.y;
LastPos = Pos;
ii = NbPtNewTrack, Track = NewTrack;
for( ; ii > 0; ii--, Track = Track->Next() )
{
if( Track->m_Flags & STARTPOINT )
{
Track->m_Start.x += dx; Track->m_Start.y += dy;
}
if( Track->m_Flags & ENDPOINT )
{
Track->m_End.x += dx; Track->m_End.y += dy;
}
}
/* dessin de la nouvelle piste */
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, GR_XOR );
/* Tracage des segments dragges */
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{
Track = pt_drag->m_Segm;
if( erase )
Track->Draw( panel, DC, GR_XOR );
if( Track->m_Flags & STARTPOINT )
{
Track->m_Start.x += dx; Track->m_Start.y += dy;
}
if( Track->m_Flags & ENDPOINT )
{
Track->m_End.x += dx; Track->m_End.y += dy;
}
Track->Draw( panel, DC, GR_XOR );
}
DisplayOpt.DisplayPcbTrackFill = track_fill_copy;
}
/***********************************************************************************/
void WinEDA_PcbFrame::Start_MoveOneTrackSegment( TRACK* track, wxDC* DC, bool Drag )
/***********************************************************************************/
{
/* Change hight light net: the new one will be hightlighted */
Old_HightLigt_Status = g_HightLigt_Status;
Old_HightLigth_NetCode = g_HightLigth_NetCode;
if( g_HightLigt_Status )
Hight_Light( DC );
if( Drag && track->Type() == TYPEVIA )
{
track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start,
track->ReturnMaskLayer(), track->GetNet() );
NewTrack = track;
NbPtNewTrack = 1;
PosInit = track->m_Start;
}
else
{
int diag = track->IsPointOnEnds( GetScreen()->m_Curseur, -1 );
wxPoint pos = (diag & STARTPOINT) ? track->m_Start : track->m_End;
Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(), track->GetNet() );
track->m_Flags |= IS_DRAGGED;
NewTrack = NULL;
NbPtNewTrack = 0;
PosInit = pos;
}
LastPos = PosInit;
DrawPanel->ManageCurseur = Show_MoveTrack;
DrawPanel->ForceCloseManageCurseur = Exit_MoveTrack;
g_HightLigth_NetCode = track->GetNet();
g_HightLigt_Status = TRUE;
DrawHightLight( DC, g_HightLigth_NetCode );
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
/**********************************************************************/
bool WinEDA_PcbFrame::PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC )
/**********************************************************************/
/* Place a dragged track segment or via */
{
int errdrc;
DRAG_SEGM* pt_drag;
if( Track == NULL )
return FALSE;
// DRC control:
if( Drc_On )
{
errdrc = Drc( this, DC, Track, m_Pcb->m_Track, 1 );
if( errdrc == BAD_DRC )
return FALSE;
/* Tracage des segments dragges */
pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext )
{
errdrc = Drc( this, DC, pt_drag->m_Segm, m_Pcb->m_Track, 1 );
if( errdrc == BAD_DRC )
return FALSE;
}
}
// DRC Ok: place track segments
Track->ClearFlags();
Track->Draw( DrawPanel, DC, GR_OR );
/* Tracage des segments dragges */
pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext )
{
Track = pt_drag->m_Segm;
Track->SetState( EDIT, OFF );
Track->ClearFlags();
Track->Draw( DrawPanel, DC, GR_OR );
}
EraseDragListe();
GetScreen()->SetModify();
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
return TRUE;
}
#if 0
/***********************************************/
void WinEDA_PcbFrame::Place_Dupl_Route( Track* Track, wxDC* DC )
/******************************************/
/*
* Routine de placement d'une piste (succession de segments)
*/
{
D_PAD* pt_pad;
TRACK* pt_track, * Track, * pt_classe, * NextS;
int masquelayer;
EDA_BaseStruct* LockPoint;
int ii, old_net_code, new_net_code, DRC_error = 0;
wxDC* DC = Cmd->DC;
ActiveDrawPanel->ManageCurseur = NULL;
if( NewTrack == NULL )
return;
old_net_code = NewTrack->net_code;
/* Placement du flag BUSY de la piste originelle, qui ne doit
* pas etre vue dans les recherches de raccordement suivantes */
ii = NbPtNewTrack; pt_track = NewTrack;
for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
{
pt_track->SetState( BUSY, ON );
}
/* Detection du nouveau net_code */
ii = NbPtNewTrack; pt_track = NewTrack;
for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
{
pt_track->net_code = 0;
}
new_net_code = 0;
ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*) pt_track->Pnext )
{
/* Localisation de la pastille ou segment en debut de segment: */
masquelayer = tab_layer[pt_track->Layer];
LockPoint = LocateLockPoint( pt_track->m_Start.x, pt_track->m_Start.y, masquelayer );
if( LockPoint )
{
if( LockPoint->Type() == TYPEPAD )
{
pt_pad = (D_PAD*) LockPoint;
new_net_code = pt_pad->net_code;
if( new_net_code > 0 )
break;
}
else /* debut de piste sur un segment de piste */
{
Track = (TRACK*) LockPoint;
new_net_code = Track->net_code;
if( new_net_code > 0 )
break;
}
}
LockPoint = LocateLockPoint( pt_track->m_End.x, pt_track->m_End.y, masquelayer );
if( LockPoint )
{
if( LockPoint->Type() == TYPEPAD )
{
pt_pad = (D_PAD*) LockPoint;
new_net_code = pt_pad->net_code;
if( new_net_code > 0 )
break;
}
else /* debut de piste sur un segment de piste */
{
Track = (TRACK*) LockPoint;
new_net_code = Track->net_code;
if( new_net_code > 0 )
break;
}
}
}
/* Mise a jour du nouveau net code de la piste */
ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*) pt_track->Pnext )
{
pt_track->net_code = new_net_code;
}
/* Controle DRC de la nouvelle piste */
ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() )
{
if( Drc_On == RUN )
if( drc( DC, pt_track, pt_pcb->Track, 1 ) == BAD_DRC )
{
if( confirmation( " Erreur DRC, Place piste:" ) == YES )
continue;
else
{
DRC_error = 1; break;
}
}
}
if( DRC_error == 0 )
{
if( FlagState == MOVE_ROUTE )
{
/* copie nouvelle piste */
pt_track = NewTrack;
NewTrack = pt_track->Copy( NbPtNewTrack );
/* effacement ancienne ( chainage et liens mauvais */
ii = NbPtNewTrack;
for( ; ii > 0; ii--, pt_track = NextS )
{
NextS = (TRACK*) pt_track->Pnext;
pt_track ->DeleteStructure();
}
test_1_net_connexion( DC, old_net_code );
}
pt_classe = NewTrack->GetBestInsertPoint();
NewTrack->Insert( pt_classe );
Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_OR );
/* Mise a jour des connexions sur pads et sur pistes */
ii = 0; pt_track = NewTrack;
for( ; ii < NbPtNewTrack; ii++, pt_track = NextS )
{
NextS = (TRACK*) pt_track->Pnext;
pt_track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
masquelayer = tab_layer[pt_track->Layer];
/* Localisation de la pastille ou segment sur debut segment: */
LockPoint = LocateLockPoint( pt_track->m_Start.x, pt_track->m_Start.y, masquelayer );
if( LockPoint )
{
pt_track->start = LockPoint;
if( LockPoint->Type() == TYPEPAD )
{ /* fin de piste sur un pad */
pt_pad = (D_PAD*) LockPoint;
pt_track->SetState( BEGIN_ONPAD, ON );
}
else /* debut de piste sur un segment de piste */
{
Track = (TRACK*) LockPoint;
CreateLockPoint( &pt_track->m_Start.x, &pt_track->m_Start.y, Track, pt_track );
}
}
/* Localisation de la pastille ou segment sur fin de segment: */
LockPoint = LocateLockPoint( pt_track->m_End.x, pt_track->m_End.y, masquelayer );
if( LockPoint )
{
pt_track->end = LockPoint;
if( LockPoint->Type() == TYPEPAD )
{ /* fin de piste sur un pad */
pt_pad = (D_PAD*) LockPoint;
pt_track->SetState( END_ONPAD, ON );
}
else /* debut de piste sur un segment de piste */
{
Track = (TRACK*) LockPoint;
CreateLockPoint( &pt_track->m_Start.x, &pt_track->m_Start.y, Track, pt_track );
}
}
}
/* Suppression du flag BUSY */
ii = NbPtNewTrack; pt_track = NewTrack;
for( ; ii > 0; ii--, pt_track = (TRACK*) pt_track->Pnext )
{
pt_track->SetState( BUSY, OFF );
}
test_1_net_connexion( DC, new_net_code );
ActiveScreen->SetModify();
}
else /* Erreur DRC: Annulation commande */
{
DisplayOpt.DisplayPcbTrackFill = SKETCH;
Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_XOR );
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
if( FlagState == MOVE_ROUTE )
{ /* Remise en position de la piste deplacee */
Track = NewTrack;
PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y;
for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext )
{
if( Track == NULL )
break;
Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY;
Track->m_End.x += PosInitX; Track->m_End.y += PosInitY;
Track->SetState( BUSY, OFF );
}
Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_OR );
}
if( FlagState == COPY_ROUTE )
{ /* Suppression copie */
for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS )
{
if( NewTrack == NULL )
break;
NextS = (TRACK*) NewTrack->Pnext;
delete NewTrack;
}
}
}
NewTrack = NULL;
m_Pcb->Display_Infos( Cmd );
if( Etat_Surbrillance )
Hight_Light( DC );
}
/************************************************/
void WinEDA_PcbFrame::Start_CopieMove_Route( TRACK* track, wxDC* DC, bool Drag )
/************************************************/
/* Routine permettant la recopie d'une piste (suite de segments) deja tracee
*/
{
int ii;
TRACK* pt_segm, * pt_track;
int masquelayer = tab_layer[ActiveScreen->Active_Layer];
wxDC* DC = Cmd->DC;
if( NewTrack )
return;
FlagState = (int) Cmd->Menu->param_inf;
/* Recherche de la piste sur la couche active (non zone) */
for( pt_segm = pt_pcb->Track; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext )
{
pt_segm = Locate_Pistes( pt_segm, masquelayer, CURSEUR_OFF_GRILLE );
if( pt_segm == NULL )
break;
break;
}
if( pt_segm != NULL )
{
if( FlagState == COPY_ROUTE )
pt_track = Marque_Une_Piste( DC, pt_segm, &NbPtNewTrack, 0 );
else
pt_track = Marque_Une_Piste( DC, pt_segm, &NbPtNewTrack, GR_XOR );
if( NbPtNewTrack ) /* Il y a NbPtNewTrack segments de piste a traiter */
{
/* effacement du flag BUSY de la piste originelle */
ii = NbPtNewTrack; pt_segm = pt_track;
for( ; ii > 0; ii--, pt_segm = (TRACK*) pt_segm->Pnext )
{
pt_segm->SetState( BUSY, OFF );
}
if( FlagState == COPY_ROUTE )
NewTrack = pt_track->Copy( NbPtNewTrack );
else
NewTrack = pt_track;
Affiche_Infos_Piste( Cmd, pt_track );
startX = ActiveScreen->Curseur_X;
startY = ActiveScreen->Curseur_Y;
Place_Dupl_Route_Item.State = WAIT;
ActiveDrawPanel->ManageCurseur = Show_Move_Piste;
DisplayOpt.DisplayPcbTrackFill = SKETCH;
Trace_Une_Piste( DC, NewTrack, NbPtNewTrack, GR_XOR );
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
PosInitX = NewTrack->m_Start.x; PosInitY = NewTrack->m_Start.y;
}
}
}
#endif
/************************************************************************/
EDA_BaseStruct* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
/************************************************************************/
/* Routine trouvant le point " d'accrochage " d'une extremite de piste.
* Ce point peut etre un PAD ou un autre segment de piste
* Retourne:
* - pointeur sur ce PAD ou:
* - pointeur sur le segment ou:
* - NULL
* Parametres d'appel:
* coord pX, pY du point tst
* masque des couches a tester
*/
{
D_PAD* pt_pad;
TRACK* ptsegm;
MODULE* Module;
/* detection du point type PAD */
pt_pad = NULL;
Module = Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
pt_pad = Locate_Pads( Module, pos, LayerMask );
if( pt_pad )
return pt_pad;
}
/* ici aucun pad n'a ete localise: detection d'un segment de piste */
ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL )
ptsegm = Locate_Pistes( Pcb->m_Track, pos, LayerMask );
return ptsegm;
}
/******************************************************************************/
TRACK* CreateLockPoint( int* pX, int* pY, TRACK* ptsegm, TRACK* refsegm )
/******************************************************************************/
/* Routine de creation d'un point intermediaire sur un segment
* le segment ptsegm est casse en 2 segments se raccordant au point pX, pY
* retourne:
* NULL si pas de nouveau point ( c.a.d si pX, pY correspondait deja
* a une extremite ou:
* pointeur sur le segment cree
* si refsegm != NULL refsegm est pointeur sur le segment incident,
* et le point cree est l'intersection des 2 axes des segments ptsegm et
* refsegm
* retourne la valeur exacte de pX et pY
* Si ptsegm pointe sur une via:
* retourne la valeur exacte de pX et pY et ptsegm,
* mais ne cree pas de point supplementaire
*
*/
{
int cX, cY;
int dx, dy; /* Coord de l'extremite du segm ptsegm / origine */
int ox, oy, fx, fy; /* coord de refsegm / origine de prsegm */
TRACK* NewTrack;
if( (ptsegm->m_Start.x == *pX) && (ptsegm->m_Start.y == *pY) )
return NULL;
if( (ptsegm->m_End.x == *pX) && (ptsegm->m_End.y == *pY) )
return NULL;
/* le point n'est pas sur une extremite de piste */
if( ptsegm->Type() == TYPEVIA )
{
*pX = ptsegm->m_Start.x; *pY = ptsegm->m_Start.y;
return ptsegm;
}
/* calcul des coord vraies du point intermediaire dans le repere d'origine
* = origine de ptsegm */
cX = *pX - ptsegm->m_Start.x;
cY = *pY - ptsegm->m_Start.y;
dx = ptsegm->m_End.x - ptsegm->m_Start.x;
dy = ptsegm->m_End.y - ptsegm->m_Start.y;
// ***** A COMPLETER : non utilise
if( refsegm )
{
ox = refsegm->m_Start.x - ptsegm->m_Start.x;
oy = refsegm->m_Start.y - ptsegm->m_Start.y;
fx = refsegm->m_End.x - ptsegm->m_Start.x;
fy = refsegm->m_End.y - ptsegm->m_Start.y;
}
/* pour que le point soit sur le segment ptsegm: cY/cX = dy/dx */
if( dx == 0 )
cX = 0;/* segm horizontal */
else
cY = (cX * dy) / dx;
/* creation du point intermediaire ( c'est a dire creation d'un nouveau
* segment, debutant au point intermediaire */
cX += ptsegm->m_Start.x; cY += ptsegm->m_Start.y;
NewTrack = ptsegm->Copy();
NewTrack->Insert( NULL, ptsegm );
/* correction du pointeur de fin du nouveau segment */
NewTrack->end = ptsegm->end;
/* le segment primitif finit au nouveau point : */
ptsegm->m_End.x = cX; ptsegm->m_End.y = cY;
ptsegm->SetState( END_ONPAD, OFF );
/* le nouveau segment debute au nouveau point : */
ptsegm = NewTrack;;
ptsegm->m_Start.x = cX; ptsegm->m_Start.y = cY;
ptsegm->SetState( BEGIN_ONPAD, OFF );
*pX = cX; *pY = cY;
return ptsegm;
}
...@@ -98,7 +98,7 @@ void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnes ...@@ -98,7 +98,7 @@ void MIN_SPAN_TREE_PADS::AddTreeToRatsnest( std::vector<RATSNEST_ITEM> &aRatsnes
int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 ) int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 )
{ {
// NOTE: The distance (weight) between a node and itself should be 0 // NOTE: The distance (weight) between a node and itself should be 0
// so we add 1 to other distances th be sure we never have 0 // so we add 1 to other distances to be sure we never have 0
// in cases other than a node and itself // in cases other than a node and itself
D_PAD* pad1 = (*m_PadsList)[aItem1]; D_PAD* pad1 = (*m_PadsList)[aItem1];
......
...@@ -60,7 +60,7 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module, ...@@ -60,7 +60,7 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module,
void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen();
if( !GetBoard() || !screen ) if( !GetBoard() || !screen )
return; return;
...@@ -71,18 +71,20 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -71,18 +71,20 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString ); TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
// Redraw the footprints // Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
{ {
module->Draw( m_canvas, DC, GR_OR ); module->Draw( m_canvas, DC, GR_OR );
} }
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
if( IsShown() ) if( IsShown() )
{ {
m_overlay.Reset(); m_overlay.Reset();
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC ); wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
overlaydc.Clear(); overlaydc.Clear();
} }
#endif #endif
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
...@@ -109,17 +111,19 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -109,17 +111,19 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness,
IU_PER_MILS, wxEmptyString ); IU_PER_MILS, wxEmptyString );
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST); GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST );
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
if( IsShown() ) if( IsShown() )
{ {
m_overlay.Reset(); m_overlay.Reset();
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC ); wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
overlaydc.Clear(); overlaydc.Clear();
} }
#endif #endif
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
...@@ -148,18 +152,18 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const ...@@ -148,18 +152,18 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
* tracks. But a white track will cover any other color since it has * tracks. But a white track will cover any other color since it has
* more bits to OR in. * more bits to OR in.
*/ */
for( TRACK* track = m_Track; track; track = track->Next() ) for( TRACK* track = m_Track; track; track = track->Next() )
{ {
track->Draw( aPanel, DC, aDrawMode ); track->Draw( aPanel, DC, aDrawMode );
} }
for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() ) for( SEGZONE* zone = m_Zone; zone; zone = zone->Next() )
{ {
zone->Draw( aPanel, DC, aDrawMode ); zone->Draw( aPanel, DC, aDrawMode );
} }
// Draw the graphic items // Draw the graphic items
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{ {
if( item->IsMoving() ) if( item->IsMoving() )
continue; continue;
...@@ -173,7 +177,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const ...@@ -173,7 +177,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
item->Draw( aPanel, DC, aDrawMode ); item->Draw( aPanel, DC, aDrawMode );
break; break;
default: default:
break; break;
} }
} }
...@@ -181,26 +185,26 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const ...@@ -181,26 +185,26 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
// Draw areas (i.e. zones) // Draw areas (i.e. zones)
for( int ii = 0; ii < GetAreaCount(); ii++ ) for( int ii = 0; ii < GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* zone = GetArea(ii); ZONE_CONTAINER* zone = GetArea( ii );
// Areas must be drawn here only if not moved or dragged, // Areas must be drawn here only if not moved or dragged,
// because these areas are drawn by ManageCursor() in a specific manner // because these areas are drawn by ManageCursor() in a specific manner
if ( (zone->GetFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED)) == 0 ) if( ( zone->GetFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED) ) == 0 )
{ {
zone->Draw( aPanel, DC, aDrawMode ); zone->Draw( aPanel, DC, aDrawMode );
zone->DrawFilledArea( aPanel, DC, aDrawMode ); zone->DrawFilledArea( aPanel, DC, aDrawMode );
} }
} }
for( MODULE* module = m_Modules; module; module = module->Next() ) for( MODULE* module = m_Modules; module; module = module->Next() )
{ {
bool display = true; bool display = true;
int layerMask = ALL_CU_LAYERS; int layerMask = ALL_CU_LAYERS;
if( module->IsMoving() ) if( module->IsMoving() )
continue; continue;
if( !IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) ) ) if( !IsElementVisible( PCB_VISIBLE( MOD_FR_VISIBLE ) ) )
{ {
if( module->GetLayer() == LAYER_N_FRONT ) if( module->GetLayer() == LAYER_N_FRONT )
display = false; display = false;
...@@ -208,10 +212,11 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const ...@@ -208,10 +212,11 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
layerMask &= ~LAYER_FRONT; layerMask &= ~LAYER_FRONT;
} }
if( !IsElementVisible( PCB_VISIBLE(MOD_BK_VISIBLE) ) ) if( !IsElementVisible( PCB_VISIBLE( MOD_BK_VISIBLE ) ) )
{ {
if( module->GetLayer() == LAYER_N_BACK ) if( module->GetLayer() == LAYER_N_BACK )
display = false; display = false;
layerMask &= ~LAYER_BACK; layerMask &= ~LAYER_BACK;
} }
...@@ -225,7 +230,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const ...@@ -225,7 +230,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const
DrawHighLight( aPanel, DC, GetHighLightNetCode() ); DrawHighLight( aPanel, DC, GetHighLightNetCode() );
// draw the BOARD's markers last, otherwise the high light will erase any marker on a pad // draw the BOARD's markers last, otherwise the high light will erase any marker on a pad
for( unsigned i=0; i < m_markers.size(); ++i ) for( unsigned i = 0; i < m_markers.size(); ++i )
{ {
m_markers[i]->Draw( aPanel, DC, aDrawMode ); m_markers[i]->Draw( aPanel, DC, aDrawMode );
} }
...@@ -244,7 +249,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode ) ...@@ -244,7 +249,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
// Redraw ZONE_CONTAINERS // Redraw ZONE_CONTAINERS
BOARD::ZONE_CONTAINERS& zones = m_ZoneDescriptorList; BOARD::ZONE_CONTAINERS& zones = m_ZoneDescriptorList;
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc ) for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
{ {
if( (*zc)->GetNet() == aNetCode ) if( (*zc)->GetNet() == aNetCode )
{ {
...@@ -253,9 +258,9 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode ) ...@@ -253,9 +258,9 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
} }
// Redraw any pads that have aNetCode // Redraw any pads that have aNetCode
for( MODULE* module = m_Modules; module; module = module->Next() ) for( MODULE* module = m_Modules; module; module = module->Next() )
{ {
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
{ {
if( pad->GetNet() == aNetCode ) if( pad->GetNet() == aNetCode )
{ {
...@@ -265,7 +270,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode ) ...@@ -265,7 +270,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* am_canvas, wxDC* DC, int aNetCode )
} }
// Redraw track and vias that have aNetCode // Redraw track and vias that have aNetCode
for( TRACK* seg = m_Track; seg; seg = seg->Next() ) for( TRACK* seg = m_Track; seg; seg = seg->Next() )
{ {
if( seg->GetNet() == aNetCode ) if( seg->GetNet() == aNetCode )
{ {
...@@ -285,12 +290,12 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule, ...@@ -285,12 +290,12 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* aModule,
{ {
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
int tmp = frame->m_DisplayPadFill; int tmp = frame->m_DisplayPadFill;
frame->m_DisplayPadFill = false; frame->m_DisplayPadFill = false;
// Draw pads. // Draw pads.
for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = aModule->m_Pads; pad; pad = pad->Next() )
{ {
if( (pad->GetLayerMask() & aLayerMask) == 0 ) if( (pad->GetLayerMask() & aLayerMask) == 0 )
continue; continue;
......
...@@ -560,6 +560,7 @@ void ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToKiPolygonList( KI_POLYGON_ ...@@ -560,6 +560,7 @@ void ZONE_CONTAINER::CopyPolygonsFromFilledPolysListToKiPolygonList( KI_POLYGON_
} }
bpl::set_points( poly, cornerslist.begin(), cornerslist.end() ); bpl::set_points( poly, cornerslist.begin(), cornerslist.end() );
aKiPolyList.push_back( poly ); aKiPolyList.push_back( poly );
} }
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <polygon_test_point_inside.h> #include <polygon_test_point_inside.h>
static bool CmpZoneSubnetValue( const BOARD_CONNECTED_ITEM* a, const BOARD_CONNECTED_ITEM* b ); static bool CmpZoneSubnetValue( const BOARD_CONNECTED_ITEM* a, const BOARD_CONNECTED_ITEM* b );
void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode ); void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode );
// This helper function sort a list of zones by netcode, // This helper function sort a list of zones by netcode,
...@@ -64,7 +65,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -64,7 +65,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
{ {
// list of pads and tracks candidates on this layer and on this net. // list of pads and tracks candidates on this layer and on this net.
// It is static to avoid multiple memory realloc. // It is static to avoid multiple memory realloc.
static std::vector <BOARD_CONNECTED_ITEM*> Candidates; static std::vector <BOARD_CONNECTED_ITEM*> candidates;
// clear .m_ZoneSubnet parameter for pads // clear .m_ZoneSubnet parameter for pads
for( MODULE* module = m_Modules; module; module = module->Next() ) for( MODULE* module = m_Modules; module; module = module->Next() )
...@@ -101,7 +102,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -101,7 +102,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
// For a given net, examine the smaller zones first slightly speed up calculation // For a given net, examine the smaller zones first slightly speed up calculation
// (25% faster) // (25% faster)
// this is only noticeable with very large boards and depends on board zones topology // this is only noticeable with very large boards and depends on board zones topology
// This is due to the fact some items are connected bt small zones ares, // This is due to the fact some items are connected by small zones ares,
// before examining large zones areas and these items are not tested after a connection is found // before examining large zones areas and these items are not tested after a connection is found
sort(zones_candidates.begin(), zones_candidates.end(), sort_areas ); sort(zones_candidates.begin(), zones_candidates.end(), sort_areas );
...@@ -123,12 +124,12 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -123,12 +124,12 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
if( oldnetcode != netcode ) if( oldnetcode != netcode )
{ {
oldnetcode = netcode; oldnetcode = netcode;
Candidates.clear(); candidates.clear();
// Build the list of pads candidates connected to the net: // Build the list of pads candidates connected to the net:
Candidates.reserve( net->m_PadInNetList.size() ); candidates.reserve( net->m_PadInNetList.size() );
for( unsigned ii = 0; ii < net->m_PadInNetList.size(); ii++ ) for( unsigned ii = 0; ii < net->m_PadInNetList.size(); ii++ )
Candidates.push_back( net->m_PadInNetList[ii] ); candidates.push_back( net->m_PadInNetList[ii] );
// Build the list of track candidates connected to the net: // Build the list of track candidates connected to the net:
TRACK* track = m_Track.GetFirst()->GetStartNetCode( netcode ); TRACK* track = m_Track.GetFirst()->GetStartNetCode( netcode );
...@@ -136,7 +137,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -136,7 +137,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
{ {
if( track->GetNet() != netcode ) if( track->GetNet() != netcode )
break; break;
Candidates.push_back( track ); candidates.push_back( track );
} }
} }
...@@ -151,14 +152,14 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -151,14 +152,14 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
subnet++; subnet++;
EDA_RECT bbox = curr_zone->CalculateSubAreaBoundaryBox( indexstart, indexend ); EDA_RECT bbox = curr_zone->CalculateSubAreaBoundaryBox( indexstart, indexend );
for( unsigned ic = 0; ic < Candidates.size(); ic++ ) for( unsigned ic = 0; ic < candidates.size(); ic++ )
{ // test if this area is connected to a board item: { // test if this area is connected to a board item:
BOARD_CONNECTED_ITEM* item = Candidates[ic]; BOARD_CONNECTED_ITEM* item = candidates[ic];
if( item->GetZoneSubNet() == subnet ) // Already merged if( item->GetZoneSubNet() == subnet ) // Already merged
continue; continue;
if( !item->IsOnLayer( curr_zone->GetLayer() ) ) if( !item->IsOnLayer( curr_zone->GetLayer() ) )
continue; continue;
wxPoint pos1, pos2; wxPoint pos1, pos2;
...@@ -201,7 +202,8 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -201,7 +202,8 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
} }
if( connected ) if( connected )
{ // Set ZoneSubnet to the current subnet value. {
// Set ZoneSubnet to the current subnet value.
// If the previous subnet is not 0, merge all items with old subnet // If the previous subnet is not 0, merge all items with old subnet
// to the new one // to the new one
int old_subnet = item->GetZoneSubNet(); int old_subnet = item->GetZoneSubNet();
...@@ -210,12 +212,14 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -210,12 +212,14 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
// Merge previous subnet with the current // Merge previous subnet with the current
if( (old_subnet > 0) && (old_subnet != subnet) ) if( (old_subnet > 0) && (old_subnet != subnet) )
{ {
for( unsigned jj = 0; jj < Candidates.size(); jj++ ) for( unsigned jj = 0; jj < candidates.size(); jj++ )
{ {
BOARD_CONNECTED_ITEM* item_to_merge = Candidates[jj]; BOARD_CONNECTED_ITEM* item_to_merge = candidates[jj];
if( old_subnet == item_to_merge->GetZoneSubNet() ) if( old_subnet == item_to_merge->GetZoneSubNet() )
{
item_to_merge->SetZoneSubNet( subnet ); item_to_merge->SetZoneSubNet( subnet );
}
} }
} // End if ( old_subnet > 0 ) } // End if ( old_subnet > 0 )
} // End if( connected ) } // End if( connected )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment