more BOARD_ITEM::Draw() support

This commit is contained in:
dickelbeck 2008-04-01 06:32:48 +00:00
parent f1b36209b1
commit a196a324d8
8 changed files with 55 additions and 107 deletions

View File

@ -13,7 +13,10 @@ email address.
+pcbnew +pcbnew
Added virtual BOARD_ITEM::Draw() and forced all BOARD_ITEM derived classes Added virtual BOARD_ITEM::Draw() and forced all BOARD_ITEM derived classes
to implement it so that all these functions are also virtual. to implement it so that all these functions are also virtual.
Made the offset argument default to the new wxPoint BOARD_ITEM::ZeroOffset Made the offset argument default to the new wxPoint BOARD_ITEM::ZeroOffset.
Coded DRAWSEGMENT::Draw() from Trace_DrawSegmentPcb() and removed the latter.
Coded EQUIPOT::Draw(), and BOARD::Draw(). Both are dummies for now, but
both can be reasonably implemented in the future.
2008-Mar-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Mar-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>

View File

@ -43,15 +43,15 @@ void ComputePlotFileName( char * FullFileName, char * Ext );
void calcule_coord_plot(int * dx, int * dy ) ; void calcule_coord_plot(int * dx, int * dy ) ;
void calcule_dim_plot(int * dx, int * dy ) ; void calcule_dim_plot(int * dx, int * dy ) ;
void Trace_Un_TextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer); void Trace_Un_TextePcb( TEXTE_PCB * pt_texte,int format_plot,int masque_layer);
/* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules, /* Trace 1 Texte type PCB , c.a.d autre que les textes sur modules,
prepare les parametres de trace de Plot_1_texte */ prepare les parametres de trace de Plot_1_texte */
void trace_1_arc(int format_plot,int cx,int cy,int start,int end, void trace_1_arc(int format_plot,int cx,int cy,int start,int end,
int rayon,int epaisseur); int rayon,int epaisseur);
void trace_1_cercle(int format_plot,int epaisseur,int cx, int cy, int rayon); void trace_1_cercle(int format_plot,int epaisseur,int cx, int cy, int rayon);
void Plot_1_texte( int format_plot, void Plot_1_texte( int format_plot,
char * ptr,int t_nbcodes, int t_orient, char * ptr,int t_nbcodes, int t_orient,
int epaisseur, int ox,int oy,int size_h,int size_v); int epaisseur, int ox,int oy,int size_h,int size_v);
/* Routine de base de trace de 1 chaine de caracteres */ /* Routine de base de trace de 1 chaine de caracteres */
void Trace_Un_DrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer ); void Trace_Un_DrawSegment( DRAWSEGMENT* PtSegm, int format_plot,int masque_layer );
@ -59,56 +59,56 @@ void Trace_Une_MirePcb( MIREPCB* PtMire, int format_plot,int masque_layer );
/* PLOTGERB.CC */ /* PLOTGERB.CC */
void trace_1_segment_GERBER(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, void trace_1_segment_GERBER(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1,
int hauteur); int hauteur);
void trace_1_cercle_GERBER( int cx, int cy, int rayon, int epaisseur); void trace_1_cercle_GERBER( int cx, int cy, int rayon, int epaisseur);
void trace_1_contour_GERBER(int cX,int cY, int dimX,int dimY, void trace_1_contour_GERBER(int cX,int cY, int dimX,int dimY,
int deltaX, int deltaY, int deltaX, int deltaY,
int dim_trait, int orient); int dim_trait, int orient);
/* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque /* Trace 1 contour rectangulaire ou trapezoidal d'orientation quelconque
donne par son centre cX, cY, ses dimensions dimX et dimY, donne par son centre cX, cY, ses dimensions dimX et dimY,
ses variations deltaX et deltaY et son orientation orient */ ses variations deltaX et deltaY et son orientation orient */
/* PLOTHPGL.CC */ /* PLOTHPGL.CC */
void Init_Trace_HPGL(); void Init_Trace_HPGL();
void Fin_Trace_HPGL(); void Fin_Trace_HPGL();
void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, void trace_1_segment_HPGL(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1,
int hauteur); int hauteur);
void trace_1_pad_TRAPEZE_HPGL(int cX,int cY, void trace_1_pad_TRAPEZE_HPGL(int cX,int cY,
int dimX,int dimY,int deltaX, int deltaY, int dimX,int dimY,int deltaX, int deltaY,
int orient,int modetrace); int orient,int modetrace);
void trace_1_pastille_RONDE_HPGL(int pos_X,int pos_Y,int diametre,int modetrace) ; void trace_1_pastille_RONDE_HPGL(int pos_X,int pos_Y,int diametre,int modetrace) ;
void trace_1_pastille_OVALE_HPGL(int pos_X,int pos_Y,int dx,int dy, void trace_1_pastille_OVALE_HPGL(int pos_X,int pos_Y,int dx,int dy,
int orient,int modetrace) ; int orient,int modetrace) ;
void trace_1_pad_rectangulaire_HPGL(int cX,int cY,int dimX,int dimY, void trace_1_pad_rectangulaire_HPGL(int cX,int cY,int dimX,int dimY,
int orient,int modetrace) ; int orient,int modetrace) ;
void Move_Plume_HPGL( int x,int y,int plume); void Move_Plume_HPGL( int x,int y,int plume);
/* deplace la plume levee (plume = 'U') ou baissee (plume = 'D') /* deplace la plume levee (plume = 'U') ou baissee (plume = 'D')
en position x,y */ en position x,y */
void Plume_HPGL( int plume ); void Plume_HPGL( int plume );
/* leve (plume = 'U') ou baisse (plume = 'D') la plume */ /* leve (plume = 'U') ou baisse (plume = 'D') la plume */
/**************/ /**************/
/* PRINTPS.CC */ /* PRINTPS.CC */
/**************/ /**************/
void trace_1_pastille_OVALE_POST(int pos_X,int pos_Y, void trace_1_pastille_OVALE_POST(int pos_X,int pos_Y,
int dx, int dy, int orient, int modetrace); int dx, int dy, int orient, int modetrace);
void trace_1_pastille_RONDE_POST(int pos_X,int pos_Y,int diametre, void trace_1_pastille_RONDE_POST(int pos_X,int pos_Y,int diametre,
int modetrace); int modetrace);
void trace_1_pad_rectangulaire_POST(int cX,int cY, void trace_1_pad_rectangulaire_POST(int cX,int cY,
int dimX,int dimY,int orient, int dimX,int dimY,int orient,
int modetrace); int modetrace);
void trace_1_contour_POST(int cX,int cY, int dimX,int dimY, void trace_1_contour_POST(int cX,int cY, int dimX,int dimY,
int deltaX, int deltaY, int deltaX, int deltaY,
int dim_trait, int orient); int dim_trait, int orient);
void trace_1_pad_TRAPEZE_POST(int cX,int cY, void trace_1_pad_TRAPEZE_POST(int cX,int cY,
int dimX,int dimY,int deltaX, int deltaY, int dimX,int dimY,int deltaX, int deltaY,
int orient,int modetrace); int orient,int modetrace);
void trace_1_segment_POST(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1, void trace_1_segment_POST(int pos_X0,int pos_Y0,int pos_X1,int pos_Y1,
int large); int large);
void trace_1_Cercle_POST(int pos_X,int pos_Y,int diametre, int width); void trace_1_Cercle_POST(int pos_X,int pos_Y,int diametre, int width);
void PlotArcPS(int x, int y, int StAngle, int EndAngle, int rayon, int width); void PlotArcPS(int x, int y, int StAngle, int EndAngle, int rayon, int width);
@ -118,13 +118,11 @@ void PlotArcPS(int x, int y, int StAngle, int EndAngle, int rayon, int width);
/***************/ /***************/
void Draw_Track_Buffer(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode, int printmasklayer); void Draw_Track_Buffer(WinEDA_DrawPanel * panel, wxDC * DC, BOARD * Pcb, int drawmode, int printmasklayer);
void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* pt_piste, int draw_mode); void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* pt_piste, int draw_mode);
void Trace_DrawSegmentPcb(WinEDA_DrawPanel * panel, wxDC * DC,
DRAWSEGMENT * PtDrawSegment, int draw_mode);
void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC, void Trace_1_texte_pcb(WinEDA_DrawPanel * panel, wxDC * DC,
TEXTE_PCB * pt_texte,int ox,int oy, int DrawMode); TEXTE_PCB * pt_texte,int ox,int oy, int DrawMode);
void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC, void Affiche_DCodes_Pistes(WinEDA_DrawPanel * panel, wxDC * DC,
BOARD * Pcb, int drawmode); BOARD * Pcb, int drawmode);
/*************/ /*************/
/* dcode.cpp */ /* dcode.cpp */

View File

@ -217,17 +217,6 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
} }
/**************************************************************************/
void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC,
DRAWSEGMENT* PtDrawSegment, int draw_mode )
/**************************************************************************/
{
// @todo Replace all calls to Trace_DrawSegmentPcb() with this call:
PtDrawSegment->Draw( panel, DC, draw_mode );
}
/*****************************************************************************************/ /*****************************************************************************************/
void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode ) void Affiche_DCodes_Pistes( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb, int drawmode )
/*****************************************************************************************/ /*****************************************************************************************/

View File

@ -509,7 +509,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR ); PtStruct->Draw( DrawPanel, DC, GR_XOR );
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
@ -1231,7 +1231,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
m_Pcb->m_Drawings = new_drawsegment; m_Pcb->m_Drawings = new_drawsegment;
new_drawsegment->m_Start += MoveVector; new_drawsegment->m_Start += MoveVector;
new_drawsegment->m_End += MoveVector; new_drawsegment->m_End += MoveVector;
Trace_DrawSegmentPcb( DrawPanel, DC, new_drawsegment, GR_OR ); new_drawsegment->Draw( DrawPanel, DC, GR_OR );
break; break;
} }

View File

@ -30,7 +30,7 @@ void WinEDA_PcbFrame::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
{ {
if( drawitem == NULL ) if( drawitem == NULL )
return; return;
Trace_DrawSegmentPcb( DrawPanel, DC, drawitem, GR_XOR ); drawitem->Draw( DrawPanel, DC, GR_XOR );
drawitem->m_Flags |= IS_MOVED; drawitem->m_Flags |= IS_MOVED;
cursor_pos = cursor_pos0 = GetScreen()->m_Curseur; cursor_pos = cursor_pos0 = GetScreen()->m_Curseur;
drawitem->Display_Infos( this ); drawitem->Display_Infos( this );
@ -52,7 +52,7 @@ void WinEDA_PcbFrame::Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
if( drawitem == NULL ) if( drawitem == NULL )
return; return;
Trace_DrawSegmentPcb( DrawPanel, DC, drawitem, GR_OR ); drawitem->Draw( DrawPanel, DC, GR_OR );
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL ); SetCurItem( NULL );
@ -77,7 +77,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* efface ancienne position */ /* efface ancienne position */
if( erase ) if( erase )
Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
wxPoint delta; wxPoint delta;
delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x; delta.x = panel->GetScreen()->m_Curseur.x - cursor_pos.x;
@ -88,7 +88,7 @@ static void Move_Segment( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
Segment->m_End.y += delta.y; Segment->m_End.y += delta.y;
cursor_pos = panel->GetScreen()->m_Curseur; cursor_pos = panel->GetScreen()->m_Curseur;
Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
DisplayOpt.DisplayDrawItems = t_fill; DisplayOpt.DisplayDrawItems = t_fill;
} }
@ -107,7 +107,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
{ {
/* effacement du segment en cours de trace */ /* effacement du segment en cours de trace */
DisplayOpt.DisplayDrawItems = SKETCH; DisplayOpt.DisplayDrawItems = SKETCH;
Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_XOR ); Segment->Draw( DrawPanel, DC, GR_XOR );
PtStruct = Segment->Pback; PtStruct = Segment->Pback;
Segment ->DeleteStructure(); Segment ->DeleteStructure();
if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) ) if( PtStruct && (PtStruct->Type() == TYPEDRAWSEGMENT ) )
@ -117,7 +117,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
} }
else else
{ {
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_XOR ); Segment->Draw( DrawPanel, DC, GR_XOR );
Segment->m_Flags = 0; Segment->m_Flags = 0;
Segment ->DeleteStructure(); Segment ->DeleteStructure();
SetCurItem( NULL ); SetCurItem( NULL );
@ -136,14 +136,14 @@ void WinEDA_PcbFrame::Drawing_SetNewWidth( DRAWSEGMENT* DrawSegm, wxDC* DC )
if( DrawSegm == NULL ) if( DrawSegm == NULL )
return; return;
Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_XOR ); DrawSegm->Draw( DrawPanel, DC, GR_XOR );
if( DrawSegm->GetLayer() == EDGE_N ) if( DrawSegm->GetLayer() == EDGE_N )
DrawSegm->m_Width = g_DesignSettings.m_EdgeSegmentWidth; DrawSegm->m_Width = g_DesignSettings.m_EdgeSegmentWidth;
else else
DrawSegm->m_Width = g_DesignSettings.m_DrawSegmentWidth; DrawSegm->m_Width = g_DesignSettings.m_DrawSegmentWidth;
Trace_DrawSegmentPcb( DrawPanel, DC, DrawSegm, GR_OR ); DrawSegm->Draw( DrawPanel, DC, GR_OR );
DrawSegm->Display_Infos( this ); DrawSegm->Display_Infos( this );
@ -182,13 +182,6 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
switch( item->Type() ) switch( item->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
if( item->GetLayer() == layer )
{
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) item, GR_XOR );
item->DeleteStructure();
}
break;
case TYPETEXTE: case TYPETEXTE:
case TYPECOTATION: case TYPECOTATION:
if( item->GetLayer() == layer ) if( item->GetLayer() == layer )
@ -228,7 +221,7 @@ static void Exit_EditEdge( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur( Panel, DC, TRUE ); Panel->ManageCurseur( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = pos; Panel->GetScreen()->m_Curseur = pos;
Segment->m_Flags = 0; Segment->m_Flags = 0;
Trace_DrawSegmentPcb( Panel, DC, Segment, GR_OR ); Segment->Draw( Panel, DC, GR_OR );
} }
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
@ -285,7 +278,7 @@ DRAWSEGMENT* WinEDA_PcbFrame::Begin_DrawSegment( DRAWSEGMENT* Segment,
GetScreen()->SetModify(); GetScreen()->SetModify();
Segment->m_Flags = 0; Segment->m_Flags = 0;
Trace_DrawSegmentPcb( DrawPanel, DC, Segment, GR_OR ); Segment->Draw( DrawPanel, DC, GR_OR );
DrawItem = Segment; DrawItem = Segment;
@ -317,7 +310,7 @@ void WinEDA_PcbFrame::End_Edge( DRAWSEGMENT* Segment, wxDC* DC )
{ {
if( Segment == NULL ) if( Segment == NULL )
return; return;
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) Segment, GR_OR ); Segment->Draw( DrawPanel, DC, GR_OR );
/* Effacement si Longueur nulle */ /* Effacement si Longueur nulle */
if( (Segment->m_Start.x == Segment->m_End.x) if( (Segment->m_Start.x == Segment->m_End.x)
@ -358,7 +351,7 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel,
/* efface ancienne position */ /* efface ancienne position */
if( erase ) if( erase )
Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) ) if( Segments_45_Only && (Segment->m_Shape == S_SEGMENT ) )
{ {
@ -370,6 +363,6 @@ static void Montre_Position_NewSegment( WinEDA_DrawPanel* panel,
Segment->m_End = panel->GetScreen()->m_Curseur; Segment->m_End = panel->GetScreen()->m_Curseur;
} }
Trace_DrawSegmentPcb( panel, DC, Segment, GR_XOR ); Segment->Draw( panel, DC, GR_XOR );
DisplayOpt.DisplayDrawItems = t_fill; DisplayOpt.DisplayDrawItems = t_fill;
} }

View File

@ -29,7 +29,6 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
*/ */
{ {
MODULE* Module; MODULE* Module;
BOARD_ITEM* PtStruct;
int drawmode = GR_COPY; int drawmode = GR_COPY;
DISPLAY_OPTIONS save_opt; DISPLAY_OPTIONS save_opt;
TRACK* pt_piste; TRACK* pt_piste;
@ -55,40 +54,21 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
printmasklayer |= EDGE_LAYER; printmasklayer |= EDGE_LAYER;
/* Draw the pcb graphic items (texts, ...) */ /* Draw the pcb graphic items (texts, ...) */
PtStruct = Pcb->m_Drawings; for( BOARD_ITEM* item = Pcb->m_Drawings; item; item = item->Next() )
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{ {
switch( PtStruct->Type() ) switch( item->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 )
break;
Trace_DrawSegmentPcb( this, DC, (DRAWSEGMENT*) PtStruct, drawmode );
break;
case TYPECOTATION: case TYPECOTATION:
if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 )
break;
( (COTATION*) PtStruct )->Draw( this, DC, drawmode );
break;
case TYPETEXTE: case TYPETEXTE:
{
if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 )
break;
( (TEXTE_PCB*) PtStruct )->Draw( this, DC, drawmode );
break;
}
case TYPEMIRE: case TYPEMIRE:
if( (g_TabOneLayerMask[ PtStruct->GetLayer()] & printmasklayer) == 0 ) if( ((1<<item->GetLayer()) & printmasklayer) == 0 )
break; break;
( (MIREPCB*) PtStruct )->Draw( this, DC, drawmode );
item->Draw( this, DC, drawmode );
break; break;
case TYPEMARKER: /* Trace des marqueurs */ case TYPEMARKER: /* Trace des marqueurs */
break;
default: default:
break; break;
} }

View File

@ -65,11 +65,6 @@ void Trace_Une_Piste( WinEDA_DrawPanel* panel,
* donc mis a 0 avant appel a la routine si la piste a tracer est la derniere * donc mis a 0 avant appel a la routine si la piste a tracer est la derniere
*/ */
void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel,
wxDC* DC,
DRAWSEGMENT* PtDrawSegment,
int mode_color );
/****************/ /****************/
/* TRACEMOD.C : */ /* TRACEMOD.C : */

View File

@ -58,13 +58,3 @@ void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track,
} }
/*************************************************************/
void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC,
DRAWSEGMENT* PtDrawSegment, int draw_mode )
/*************************************************************/
{
// @todo Replace all calls to Trace_DrawSegmentPcb() with this call:
PtDrawSegment->Draw( panel, DC, draw_mode );
}