kicad/pcbnew/trpiste.cpp

170 lines
5.0 KiB
C++
Raw Normal View History

/*****************************************************************/
/* Routines de tracage des pistes ( Toutes, 1 piste, 1 segment ) */
/*****************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "trigo.h"
#include "protos.h"
/* variables locales : */
/*********************************************************************************/
2007-08-23 04:28:46 +00:00
void Trace_Pistes( WinEDA_DrawPanel* panel, BOARD* Pcb, wxDC* DC, int drawmode )
/********************************************************************************/
2007-08-23 04:28:46 +00:00
/* Draw all tracks and zones.
2007-08-23 04:28:46 +00:00
*/
{
TRACK * track = Pcb->m_Track;
2007-08-23 04:28:46 +00:00
for( ; track != NULL; track = track->Next() )
{
track->Draw( panel, DC, drawmode );
}
SEGZONE * zone = Pcb->m_Zone;
for( ; zone != NULL; zone = zone->Next() )
2007-08-23 04:28:46 +00:00
{
zone->Draw( panel, DC, drawmode );
2007-08-23 04:28:46 +00:00
}
}
/************************************************************************/
2007-08-23 04:28:46 +00:00
void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track,
int nbsegment, int draw_mode )
/************************************************************************/
2007-08-23 04:28:46 +00:00
/* routine de trace de n segments consecutifs en memoire.
2007-08-23 04:28:46 +00:00
* Utile pour monter une piste en cours de trace car les segments de cette
* piste sont alors contigus en memoire
* Parametres :
* pt_start_piste = adresse de depart de la liste des segments
* nbsegment = nombre de segments a tracer
* draw_mode = mode ( GR_XOR, GR_OR..)
* ATTENTION:
* le point de depart d'une piste suivante DOIT exister: peut etre
* donc mis a 0 avant appel a la routine si la piste a tracer est la derniere
*/
{
2007-08-23 04:28:46 +00:00
if( Track == NULL )
return;
for( ; nbsegment > 0; nbsegment--, Track = (TRACK*) Track->Pnext )
{
if( Track == NULL )
break;
Track->Draw( panel, DC, draw_mode );
}
}
2007-08-23 04:28:46 +00:00
/*************************************************************/
2007-08-23 04:28:46 +00:00
void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC,
DRAWSEGMENT* PtDrawSegment, int draw_mode )
/*************************************************************/
2007-08-23 04:28:46 +00:00
/* Affichage d'un segment type drawing PCB:
2007-08-23 04:28:46 +00:00
* draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND)
* Les contours sont de differents type:
* segment
* cercle
* arc
*/
{
2007-08-23 04:28:46 +00:00
int ux0, uy0, dx, dy;
int l_piste;
int color, mode;
int zoom;
int rayon;
color = g_DesignSettings.m_LayerColor[PtDrawSegment->GetLayer()];
if( color & ITEM_NOT_SHOW )
return;
if( panel )
zoom = panel->GetZoom();
else
zoom = ActiveScreen->GetZoom();
GRSetDrawMode( DC, draw_mode );
l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */
/* coord de depart */
ux0 = PtDrawSegment->m_Start.x;
uy0 = PtDrawSegment->m_Start.y;
/* coord d'arrivee */
dx = PtDrawSegment->m_End.x;
dy = PtDrawSegment->m_End.y;
mode = DisplayOpt.DisplayDrawItems;
if( PtDrawSegment->m_Flags & FORCE_SKETCH )
mode = SKETCH;
if( l_piste < (L_MIN_DESSIN * zoom) )
mode = FILAIRE;
switch( PtDrawSegment->m_Shape )
{
case S_CIRCLE:
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
if( mode == FILAIRE )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, color );
}
else if( mode == SKETCH )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, color );
}
else
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width, color );
}
break;
case S_ARC:
{
int StAngle, EndAngle;
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
StAngle = (int) ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + PtDrawSegment->m_Angle;
if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle );
if( mode == FILAIRE )
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color );
else if( mode == SKETCH )
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon - l_piste, color );
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon + l_piste, color );
}
else
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, PtDrawSegment->m_Width, color );
}
}
break;
default:
if( mode == FILAIRE )
GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color );
else if( mode == SKETCH )
{
GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
PtDrawSegment->m_Width, color );
}
else
{
GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
PtDrawSegment->m_Width, color );
}
break;
}
}