Commit 0d790e57 authored by dickelbeck's avatar dickelbeck

polygon work, EDGE_MODULE::m_PolyPoints is now std::vector

parent fadacffc
...@@ -5,6 +5,17 @@ Started 2007-June-11 ...@@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Dec-29 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++all
* gr_basic.h DOXYGEN comments. made a couple functions static and removed
those from gr_basic.h since they are private to gr_basic.c. changed the
polygon code to use wxPoints since that is what the underlying wxWidgets
API uses.
++gerbview
More work on drawing polygons, erasure still work in progress. Will
probably switch to ZONEs from SEG_ZONEs for polygons.
2008-Dec-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
......
...@@ -269,7 +269,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, ...@@ -269,7 +269,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC,
*(coordptr + 2), *(coordptr + 3), aWidth, aColor ); *(coordptr + 2), *(coordptr + 3), aWidth, aColor );
} }
else else
GRPoly( &aPanel->m_ClipBox, DC, ii / 2, coord, 0, GRPoly( &aPanel->m_ClipBox, DC, ii / 2, (wxPoint*)coord, 0,
aWidth, aColor, aColor ); aWidth, aColor, aColor );
} }
plume = f_cod; ii = 0; plume = f_cod; ii = 0;
......
...@@ -828,21 +828,19 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int ...@@ -828,21 +828,19 @@ void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int
} }
static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, int* Points ) static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
{ {
int ii;
int Xmin, Xmax, Ymin, Ymax; int Xmin, Xmax, Ymin, Ymax;
Xmin = Xmax = Points[0]; Xmin = Xmax = Points[0].x;
Ymin = Ymax = Points[1]; Ymin = Ymax = Points[0].y;
for( ii = 1; ii < n; ii++ ) // calcul du rectangle d'encadrement for( int ii = 1; ii < n; ii++ ) // calcul du rectangle d'encadrement
{ {
int jj = ii * 2; Xmin = MIN( Xmin, Points[ii].x );
Xmin = MIN( Xmin, Points[jj] ); Xmax = MAX( Xmax, Points[ii].x );
Xmax = MAX( Xmax, Points[jj] ); Ymin = MIN( Ymin, Points[ii].y );
Ymin = MIN( Ymin, Points[jj + 1] ); Ymax = MAX( Ymax, Points[ii].y );
Ymax = MAX( Ymax, Points[jj + 1] );
} }
xcliplo = ClipBox->GetX(); xcliplo = ClipBox->GetX();
...@@ -866,7 +864,7 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, int* Points ) ...@@ -866,7 +864,7 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, int* Points )
/************************************************************************/ /************************************************************************/
/* Routine to draw a new polyline and fill it if Fill, in screen space. */ /* Routine to draw a new polyline and fill it if Fill, in screen space. */
/************************************************************************/ /************************************************************************/
void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, bool Fill, static void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
int width, int Color, int BgColor ) int width, int Color, int BgColor )
{ {
if( !IsGRSPolyDrawable( ClipBox, n, Points ) ) if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
...@@ -877,19 +875,19 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, bool Fill, ...@@ -877,19 +875,19 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, bool Fill,
if( Fill && ( n > 2 ) ) if( Fill && ( n > 2 ) )
{ {
GRSetBrush( DC, BgColor, FILLED ); GRSetBrush( DC, BgColor, FILLED );
DC->DrawPolygon( n, (wxPoint*) Points ); DC->DrawPolygon( n, Points );
} }
else else
{ {
int endx = Points[n * 2 - 2]; wxPoint endPt = Points[n-1];
int endy = Points[n * 2 - 1];
GRSetBrush( DC, Color ); GRSetBrush( DC, Color );
DC->DrawLines( n, (wxPoint*) Points ); DC->DrawLines( n, Points );
// The last point is not drawn by DrawLine and DrawLines // The last point is not drawn by DrawLine and DrawLines
// Add it if the polygon is not closed // Add it if the polygon is not closed
if ( endx != Points[0] || endy != Points[1] ) if( endPt != Points[0] )
DC->DrawPoint(endx, endy); DC->DrawPoint(endPt.x, endPt.y);
} }
} }
...@@ -897,61 +895,56 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, bool Fill, ...@@ -897,61 +895,56 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, bool Fill,
/******************************************************************************/ /******************************************************************************/
/* Routine to draw a new closed polyline and fill it if Fill, in screen space */ /* Routine to draw a new closed polyline and fill it if Fill, in screen space */
/******************************************************************************/ /******************************************************************************/
void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int aPointCount, wxPoint aPoints[],
bool Fill, int Color, int BgColor )
{
GRSClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
}
void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points,
bool Fill, int width, int Color, int BgColor ) bool Fill, int width, int Color, int BgColor )
{ {
int startx, starty; if( !IsGRSPolyDrawable( ClipBox, aPointCount, aPoints ) )
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
return; return;
GRSetColorPen( DC, Color, width ); GRSetColorPen( DC, Color, width );
if( Fill && ( n > 2 ) ) if( Fill && ( aPointCount > 2 ) )
{ {
GRSMoveTo( Points[n * 2 - 2], Points[n * 2 - 1] ); GRSMoveTo( aPoints[aPointCount-1].x, aPoints[aPointCount-1].y );
GRSetBrush( DC, BgColor, FILLED ); GRSetBrush( DC, BgColor, FILLED );
DC->DrawPolygon( n, (wxPoint*) Points, 0, 0, wxODDEVEN_RULE ); DC->DrawPolygon( aPointCount, aPoints, 0, 0, wxODDEVEN_RULE );
} }
else else
{ {
startx = Points[n * 2 - 2]; starty = Points[n * 2 - 1];
GRSetBrush( DC, BgColor ); GRSetBrush( DC, BgColor );
DC->DrawLines( n, (wxPoint*) Points ); DC->DrawLines( aPointCount, aPoints );
/* Fermeture du polygone */ /* Fermeture du polygone */
if( (startx != Points[0]) || (starty != Points[1]) ) if( aPoints[aPointCount-1] != aPoints[0] )
{ {
GRSLine( ClipBox, DC, Points[0], Points[1], startx, starty, width, Color ); GRSLine( ClipBox, DC, aPoints[0].x, aPoints[0].y,
aPoints[aPointCount-1].x, aPoints[aPointCount-1].y, width, Color );
} }
} }
} }
/* not used
static void GRSClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int Color, int BgColor )
{
GRSClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
}
*/
/************************************************************************/ /************************************************************************/
/* Routine to draw a new polyline and fill it if Fill, in drawing space. */ /* Routine to draw a new polyline and fill it if Fill, in drawing space. */
/************************************************************************/ /************************************************************************/
void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, int Color, int BgColor ) bool Fill, int width, int Color, int BgColor )
{ {
int ii, jj; for( int i=0; i<n; ++i )
width = ZoomValue( width );
for( ii = 0; ii < n; ii++ )
{ {
jj = ii << 1; Points[i].x = GRMapX( Points[i].x );
Points[jj] = GRMapX( Points[jj] ); Points[i].y = GRMapY( Points[i].y );
jj++;
Points[jj] = GRMapY( Points[jj] );
} }
width = ZoomValue( width );
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor ); GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
} }
...@@ -959,27 +952,23 @@ void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, ...@@ -959,27 +952,23 @@ void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points,
/**************************************************************************/ /**************************************************************************/
/* Routine to draw a closed polyline and fill it if Fill, in object space */ /* Routine to draw a closed polyline and fill it if Fill, in object space */
/**************************************************************************/ /**************************************************************************/
void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int Color, int BgColor ) bool Fill, int Color, int BgColor )
{ {
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor ); GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
} }
void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, int Color, int BgColor ) bool Fill, int width, int Color, int BgColor )
{ {
int ii, jj; for( int i=0; i<n; ++i )
width = ZoomValue( width );
for( ii = 0; ii < n; ii++ )
{ {
jj = ii << 1; Points[i].x = GRMapX( Points[i].x );
Points[jj] = GRMapX( Points[jj] ); Points[i].y = GRMapY( Points[i].y );
jj++;
Points[jj] = GRMapY( Points[jj] );
} }
width = ZoomValue( width );
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor ); GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
} }
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
/*******************************************************************/ /*******************************************************************/
Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent, Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos, const wxString& text ) : const wxPoint& pos,
const wxString& text ) :
SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ), SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ),
EDA_TextStruct( text ) EDA_TextStruct( text )
/*******************************************************************/ /*******************************************************************/
...@@ -76,16 +77,23 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -76,16 +77,23 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
EDA_Colors txtcolor; EDA_Colors txtcolor;
int posx, tposx, posy, size2; int posx, tposx, posy, size2;
wxSize size; wxSize size;
int NbSegm, coord[20]; int NbSegm;
// @todo use wxPoints here
int coord[20];
int LineWidth = g_DrawMinimunLineWidth; int LineWidth = g_DrawMinimunLineWidth;
if( Color >= 0 ) if( Color >= 0 )
txtcolor = (EDA_Colors)Color; txtcolor = (EDA_Colors) Color;
else else
txtcolor = ReturnLayerColor( m_Layer ); txtcolor = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size; posx = m_Pos.x + offset.x;
posy = m_Pos.y + offset.y;
size = m_Size;
if( !m_Text.IsEmpty() ) if( !m_Text.IsEmpty() )
{ {
if( m_Edge ) if( m_Edge )
...@@ -110,7 +118,10 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -110,7 +118,10 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
size.y = -size.y; size.y = -size.y;
} }
coord[0] = posx; coord[1] = posy; size2 = size.x / 2; coord[0] = posx;
coord[1] = posy;
size2 = size.x / 2;
NbSegm = 0; NbSegm = 0;
switch( m_Shape ) switch( m_Shape )
...@@ -154,7 +165,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -154,7 +165,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
} }
int FillShape = FALSE; int FillShape = FALSE;
GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */ GRPoly( &panel->m_ClipBox, DC, NbSegm, (wxPoint*) coord,
FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */
} }
...@@ -202,6 +214,7 @@ bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const ...@@ -202,6 +214,7 @@ bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const
return true; return true;
} }
#if defined(DEBUG) #if defined(DEBUG)
void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os ) void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os )
{ {
...@@ -214,7 +227,7 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os ) ...@@ -214,7 +227,7 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os )
<< std::flush; << std::flush;
// NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n"; // NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -393,15 +393,16 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs ...@@ -393,15 +393,16 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
} }
CreateGraphicShape( Poly, AnchorPos ); CreateGraphicShape( Poly, AnchorPos );
GRPoly( &panel->m_ClipBox, DC, Poly[0], Poly + 1, 0, width, color, color ); GRPoly( &panel->m_ClipBox, DC, Poly[0], (wxPoint*)(Poly + 1), 0, width, color, color );
if( m_IsDangling ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
} }
/** function CreateGraphicShape /**
* Calculates the graphic shape (a polygon) associated to the text * Function CreateGraphicShape
* calculates the graphic shape (a polygon) associated to the text
* @param corner_list = coordinates list fill with polygon corners ooordinates (size > 20) * @param corner_list = coordinates list fill with polygon corners ooordinates (size > 20)
* @param Pos = Postion of the shape * @param Pos = Postion of the shape
* format list is * format list is
...@@ -414,13 +415,14 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos ) ...@@ -414,13 +415,14 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
int imax = *Template; Template++; int imax = *Template; Template++;
*corner_list = imax; corner_list++; *corner_list++ = imax;
for( int ii = 0; ii < imax; ii++ ) for( int ii = 0; ii < imax; ii++ )
{ {
*corner_list = ( HalfSize * (*Template) ) + Pos.x; *corner_list++ = ( HalfSize * (*Template) ) + Pos.x;
corner_list++; Template++; Template++;
*corner_list = ( HalfSize * (*Template) ) + Pos.y;
corner_list++; Template++; *corner_list++ = ( HalfSize * (*Template) ) + Pos.y;
Template++;
} }
} }
...@@ -546,7 +548,7 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr ...@@ -546,7 +548,7 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
} }
CreateGraphicShape( Poly, AnchorPos ); CreateGraphicShape( Poly, AnchorPos );
GRPoly( &panel->m_ClipBox, DC, Poly[0], Poly + 1, 0, width, color, color ); GRPoly( &panel->m_ClipBox, DC, Poly[0], (wxPoint*) (Poly + 1), 0, width, color, color );
if( m_IsDangling ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, AnchorPos, color ); DrawDanglingSymbol( panel, DC, AnchorPos, color );
......
...@@ -281,14 +281,14 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -281,14 +281,14 @@ void LibDrawPolyline::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR ) if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
Buf_Poly_Drawings, 1, linewidth, color, (wxPoint*) Buf_Poly_Drawings, 1, linewidth, color,
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) ); ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE ) else if( fill == FILLED_SHAPE )
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
Buf_Poly_Drawings, 1, linewidth, color, color ); (wxPoint*) Buf_Poly_Drawings, 1, linewidth, color, color );
else else
GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount, GRPoly( &aPanel->m_ClipBox, aDC, m_CornersCount,
Buf_Poly_Drawings, 0, linewidth, color, color ); (wxPoint*) Buf_Poly_Drawings, 0, linewidth, color, color );
} }
......
...@@ -81,9 +81,49 @@ static wxPoint LastPosition; ...@@ -81,9 +81,49 @@ static wxPoint LastPosition;
/* Local Functions (are lower case since they are private to this source file) */ /* Local Functions (are lower case since they are private to this source file) */
/**
* Function fillCircularTRACK
* initializes a given TRACK so that it can draw a circle which is not filled and
* has a given pen width (\a aPenWidth ).
*
* @param aTrack The TRACK to fill in.
* @param Dcode_index The DCODE value, like D14
* @param aLayer The layer index to set into the TRACK
* @param aPos The center point of the flash
* @param aDiameter The diameter of the round flash
* @param aPenWidth The width of the pen used to draw the circle's circumfrance.
* @param isDark True if flash is positive and should use a drawing
* color other than the background color, else use the background color
* when drawing so that an erasure happens.
*/
static void fillCircularTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
const wxPoint& aPos, int aDiameter, int aPenWidth, bool isDark )
{
aTrack->m_Shape = S_CIRCLE;
aTrack->m_Width = aPenWidth;
aTrack->SetLayer( aLayer );
aTrack->SetNet( Dcode_index );
// When drawing a TRACK with shape S_CIRCLE, the hypotenuse (i.e. distance)
// between the Start and End points gives the radius of the circle.
aTrack->m_Start = aTrack->m_End = aPos;
aTrack->m_End.x += max(0, (aDiameter + 1)/2);
NEGATE( aTrack->m_Start.y );
NEGATE( aTrack->m_End.y );
if( !isDark )
{
aTrack->m_Flags |= DRAW_ERASED;
}
}
/** /**
* Function fillRoundFlashTRACK * Function fillRoundFlashTRACK
* initializes a given TRACK so that it can draw a flash D code which is round. * initializes a given TRACK so that it can draw a circle which is filled and
* has no pen border.
* *
* @param aTrack The TRACK to fill in. * @param aTrack The TRACK to fill in.
* @param Dcode_index The DCODE value, like D14 * @param Dcode_index The DCODE value, like D14
...@@ -114,12 +154,12 @@ static void fillRoundFlashTRACK( TRACK* aTrack, int Dcode_index, int aLayer, ...@@ -114,12 +154,12 @@ static void fillRoundFlashTRACK( TRACK* aTrack, int Dcode_index, int aLayer,
/** /**
* Function fillOvalOrRectFlashTRACK * Function fillOvalOrRectFlashTRACK
* initializes a given TRACK so that it can draw an oval or rectangular flash D code. * initializes a given TRACK so that it can draw an oval or rectangular filled rectangle.
* *
* @param aTrack The TRACK to fill in. * @param aTrack The TRACK to fill in.
* @param Dcode_index The DCODE value, like D14 * @param Dcode_index The DCODE value, like D14
* @param aLayer The layer index to set into the TRACK * @param aLayer The layer index to set into the TRACK
* @param aPos The center point of the flash * @param aPos The center point of the rectangle
* @param aSize The size of the flash * @param aSize The size of the flash
* @param aShape What type of flash, S_SPOT_OVALE or S_SPOT_RECT * @param aShape What type of flash, S_SPOT_OVALE or S_SPOT_RECT
* @param isDark True if flash is positive and should use a drawing * @param isDark True if flash is positive and should use a drawing
...@@ -810,6 +850,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -810,6 +850,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
APERTURE_T aperture = APT_CIRCLE; APERTURE_T aperture = APT_CIRCLE;
TRACK* track; TRACK* track;
BOARD* pcb = frame->m_Pcb;
int activeLayer = frame->GetScreen()->m_Active_Layer; int activeLayer = frame->GetScreen()->m_Active_Layer;
...@@ -841,24 +882,35 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -841,24 +882,35 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
switch( D_commande ) switch( D_commande )
{ {
case 1: // code D01 Draw line, exposure ON case 1: // code D01 Draw line, exposure ON
{
m_Exposure = true; m_Exposure = true;
SEGZONE* edge_poly = new SEGZONE( frame->m_Pcb ); SEGZONE* edge_poly;
frame->m_Pcb->m_Zone.Append( edge_poly ); edge_poly = new SEGZONE( pcb );
pcb->m_Zone.Append( edge_poly );
edge_poly->SetLayer( activeLayer ); edge_poly->SetLayer( activeLayer );
edge_poly->m_Width = 1; edge_poly->m_Width = 1;
edge_poly->m_Start = m_PreviousPos; edge_poly->m_Start = m_PreviousPos;
NEGATE( edge_poly->m_Start.y ); NEGATE( edge_poly->m_Start.y );
edge_poly->m_End = m_CurrentPos; edge_poly->m_End = m_CurrentPos;
NEGATE( edge_poly->m_End.y ); NEGATE( edge_poly->m_End.y );
edge_poly->SetNet( m_PolygonFillModeState ); edge_poly->SetNet( m_PolygonFillModeState );
// the first track of each polygon has a netcode of zero, otherwise one.
// set the erasure flag in that special track, if a negative polygon.
if( !m_PolygonFillModeState )
{
if( m_LayerNegative ^ m_ImageNegative )
edge_poly->m_Flags |= DRAW_ERASED;
D(printf("\nm_Flags=0x%08X\n", edge_poly->m_Flags );)
}
m_PreviousPos = m_CurrentPos; m_PreviousPos = m_CurrentPos;
m_PolygonFillModeState = 1; m_PolygonFillModeState = 1;
break; break;
}
case 2: // code D2: exposure OFF (i.e. "move to") case 2: // code D2: exposure OFF (i.e. "move to")
m_Exposure = false; m_Exposure = false;
...@@ -888,8 +940,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -888,8 +940,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
switch( m_Iterpolation ) switch( m_Iterpolation )
{ {
case GERB_INTERPOL_LINEAR_1X: case GERB_INTERPOL_LINEAR_1X:
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillLineTRACK( track, dcode, activeLayer, fillLineTRACK( track, dcode, activeLayer,
m_PreviousPos, m_CurrentPos, m_PreviousPos, m_CurrentPos,
size.x, !(m_LayerNegative ^ m_ImageNegative) ); size.x, !(m_LayerNegative ^ m_ImageNegative) );
...@@ -903,8 +955,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -903,8 +955,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
case GERB_INTERPOL_ARC_NEG: case GERB_INTERPOL_ARC_NEG:
case GERB_INTERPOL_ARC_POS: case GERB_INTERPOL_ARC_POS:
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillArcTRACK( track, dcode, activeLayer, fillArcTRACK( track, dcode, activeLayer,
m_PreviousPos, m_CurrentPos, m_IJPos, m_PreviousPos, m_CurrentPos, m_IJPos,
size.x, m_Iterpolation==GERB_INTERPOL_ARC_NEG ? false : true, size.x, m_Iterpolation==GERB_INTERPOL_ARC_NEG ? false : true,
...@@ -939,8 +991,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -939,8 +991,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
{ {
case APT_LINE: // APT_LINE is not in the spec, don't know why it's here case APT_LINE: // APT_LINE is not in the spec, don't know why it's here
case APT_CIRCLE: case APT_CIRCLE:
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillRoundFlashTRACK( track, dcode, activeLayer, fillRoundFlashTRACK( track, dcode, activeLayer,
m_CurrentPos, m_CurrentPos,
size.x, !(m_LayerNegative ^ m_ImageNegative) ); size.x, !(m_LayerNegative ^ m_ImageNegative) );
...@@ -948,8 +1000,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -948,8 +1000,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
case APT_OVAL: case APT_OVAL:
case APT_RECT: case APT_RECT:
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
m_CurrentPos, size, m_CurrentPos, size,
aperture == APT_RECT ? S_SPOT_RECT : S_SPOT_OVALE, aperture == APT_RECT ? S_SPOT_RECT : S_SPOT_OVALE,
...@@ -975,8 +1027,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -975,8 +1027,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
curPos += mapPt( p->params[2].GetValue( tool ), p->params[3].GetValue( tool ), m_GerbMetric ); curPos += mapPt( p->params[2].GetValue( tool ), p->params[3].GetValue( tool ), m_GerbMetric );
int diameter = scale( p->params[1].GetValue( tool ), m_GerbMetric ); int diameter = scale( p->params[1].GetValue( tool ), m_GerbMetric );
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillRoundFlashTRACK( track, dcode, activeLayer, fillRoundFlashTRACK( track, dcode, activeLayer,
m_CurrentPos, m_CurrentPos,
diameter, exposure ); diameter, exposure );
...@@ -1004,8 +1056,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1004,8 +1056,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
wxPoint midPoint( (start.x + end.x)/2, (start.y+end.y)/2 ); wxPoint midPoint( (start.x + end.x)/2, (start.y+end.y)/2 );
curPos += midPoint; curPos += midPoint;
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, size, S_SPOT_RECT, curPos, size, S_SPOT_RECT,
exposure ); exposure );
...@@ -1019,8 +1071,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1019,8 +1071,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
size.x = msize.x; size.x = msize.x;
size.y = msize.y; size.y = msize.y;
curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric ); curPos += mapPt( p->params[3].GetValue( tool ), p->params[4].GetValue( tool ), m_GerbMetric );
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, size, S_SPOT_RECT, curPos, size, S_SPOT_RECT,
exposure ); exposure );
...@@ -1038,8 +1090,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1038,8 +1090,8 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
// need the middle, so adjust from the lower left // need the middle, so adjust from the lower left
curPos.y += size.y/2; curPos.y += size.y/2;
curPos.x += size.x/2; curPos.x += size.x/2;
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer, fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, size, S_SPOT_RECT, curPos, size, S_SPOT_RECT,
exposure ); exposure );
...@@ -1053,13 +1105,13 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1053,13 +1105,13 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
curPos += mapPt( p->params[0].GetValue( tool ), p->params[1].GetValue( tool ), m_GerbMetric ); curPos += mapPt( p->params[0].GetValue( tool ), p->params[1].GetValue( tool ), m_GerbMetric );
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillRoundFlashTRACK( track, dcode, activeLayer, curPos, fillRoundFlashTRACK( track, dcode, activeLayer, curPos,
outerDiam, !(m_LayerNegative ^ m_ImageNegative) ); outerDiam, !(m_LayerNegative ^ m_ImageNegative) );
track = new TRACK( frame->m_Pcb ); track = new TRACK( pcb );
frame->m_Pcb->m_Track.Append( track ); pcb->m_Track.Append( track );
fillRoundFlashTRACK( track, dcode, activeLayer, curPos, fillRoundFlashTRACK( track, dcode, activeLayer, curPos,
innerDiam, (m_LayerNegative ^ m_ImageNegative) ); innerDiam, (m_LayerNegative ^ m_ImageNegative) );
...@@ -1069,10 +1121,46 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC, ...@@ -1069,10 +1121,46 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, wxDC* DC,
} }
break; break;
case AMP_MOIRE:
{
curPos += mapPt( p->params[0].GetValue( tool ), p->params[1].GetValue( tool ), m_GerbMetric );
// e.g.: "6,0,0,0.125,.01,0.01,3,0.003,0.150,0"
int outerDiam = scale( p->params[2].GetValue(tool), m_GerbMetric );
int penThickness = scale( p->params[3].GetValue(tool), m_GerbMetric );
int gap = scale( p->params[4].GetValue(tool), m_GerbMetric );
int numCircles = p->params[5].GetValue(tool);
int crossHairThickness = scale( p->params[6].GetValue(tool), m_GerbMetric );
int crossHairLength = scale( p->params[7].GetValue(tool), m_GerbMetric );
// ignore rotation, not supported
int diamAdjust = 2 * (gap + penThickness); // adjust outerDiam by this on each nested circle
for( int i=0; i<numCircles; ++i, outerDiam -= diamAdjust )
{
track = new TRACK( pcb );
pcb->m_Track.Append( track );
fillCircularTRACK( track, dcode, activeLayer, curPos, outerDiam,
penThickness, !(m_LayerNegative ^ m_ImageNegative) );
}
track = new TRACK( pcb );
pcb->m_Track.Append( track );
fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, wxSize(crossHairThickness,crossHairLength),
S_SPOT_RECT, !(m_LayerNegative ^ m_ImageNegative) );
track = new TRACK( pcb );
pcb->m_Track.Append( track );
// swap x and y in wxSize() for this one
fillOvalOrRectFlashTRACK( track, dcode, activeLayer,
curPos, wxSize(crossHairLength,crossHairThickness),
S_SPOT_RECT, !(m_LayerNegative ^ m_ImageNegative) );
}
break;
case AMP_EOF: case AMP_EOF:
case AMP_OUTLINE: case AMP_OUTLINE:
case AMP_POLYGON: case AMP_POLYGON:
case AMP_MOIRE:
default: default:
// not yet supported, waiting for you. // not yet supported, waiting for you.
break; break;
......
...@@ -113,12 +113,13 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -113,12 +113,13 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
if( !m_Pcb ) if( !m_Pcb )
return; return;
bool erase;
// Draw filled polygons // Draw filled polygons
#define NBMAX 20000 std::vector<wxPoint> coords;
int nbpoints = 0;
int nbpointsmax = NBMAX; // minimize reallocations of the vector's internal array by starting with a good sized one.
int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 ); coords.reserve(20000);
int* ptcoord = coord;
for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
{ {
...@@ -127,36 +128,37 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -127,36 +128,37 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
if( track->GetNet() == 0 ) // StartPoint if( track->GetNet() == 0 ) // StartPoint
{ {
if( nbpoints ) // we have found a new polygon: Draw the old polygon if( coords.size() ) // we have found a new polygon: Draw the old polygon
{ {
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; int Color;
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0; int filled;
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, if( erase )
filled, Color, Color ); {
D(printf("erase\n");)
Color = g_DrawBgColor;
filled = true;
}
else
{
D(printf("NO erase\n");)
Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
} }
nbpoints = 2; GRClosedPoly( &DrawPanel->m_ClipBox, DC, coords.size(), &coords[0],
ptcoord = coord; filled, Color, Color );
}
*ptcoord++ = track->m_Start.x; erase = ( track->m_Flags & DRAW_ERASED ) ? true : false;
*ptcoord++ = track->m_Start.y;
*ptcoord++ = track->m_End.x; coords.clear();
*ptcoord++ = track->m_End.y; coords.push_back( track->m_Start );
coords.push_back( track->m_End );
} }
else else
{ {
if( nbpoints >= nbpointsmax ) coords.push_back( track->m_End );
{
nbpointsmax *= 2;
coord = (int*) realloc( coord, nbpointsmax * sizeof(int) * 2 );
ptcoord = coord + nbpointsmax;
}
nbpoints++;
*ptcoord++ = track->m_End.x;
*ptcoord++ = track->m_End.y;
} }
if( track->Next() == NULL ) // Last point if( track->Next() == NULL ) // Last point
...@@ -164,13 +166,11 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -164,13 +166,11 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; int Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0; int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, GRClosedPoly( &DrawPanel->m_ClipBox, DC, coords.size(), &coords[0],
filled, Color, Color ); filled, Color, Color );
} }
} }
free( coord );
// Draw tracks and flashes down here. This will probably not be a final solution to drawing order issues // Draw tracks and flashes down here. This will probably not be a final solution to drawing order issues
Draw_Track_Buffer( DrawPanel, DC, m_Pcb, draw_mode, printmasklayer ); Draw_Track_Buffer( DrawPanel, DC, m_Pcb, draw_mode, printmasklayer );
......
...@@ -64,7 +64,6 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -64,7 +64,6 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
int l_piste; int l_piste;
int color; int color;
int zoom; int zoom;
int rayon;
int fillopt; int fillopt;
static bool show_err; static bool show_err;
...@@ -93,32 +92,35 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -93,32 +92,35 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
zoom = panel->GetZoom(); zoom = panel->GetZoom();
rayon = l_piste = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH;
switch( track->m_Shape ) switch( track->m_Shape )
{ {
case S_CIRCLE: case S_CIRCLE:
rayon = (int) hypot( (double) (track->m_End.x - track->m_Start.x), {
int radius = (int) hypot( (double) (track->m_End.x - track->m_Start.x),
(double) (track->m_End.y - track->m_Start.y) ); (double) (track->m_End.y - track->m_Start.y) );
if( (l_piste / zoom) < L_MIN_DESSIN )
int halfPenWidth = track->m_Width >> 1;
if( (halfPenWidth / zoom) < L_MIN_DESSIN )
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon, 0, color ); radius, 0, color );
} }
if( fillopt == SKETCH ) if( fillopt == SKETCH )
{ {
// draw the border of the pen's path using two circles, each as narrow as possible
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon - l_piste, 0, color ); radius - halfPenWidth, 0, color );
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon + l_piste, 0, color ); radius + halfPenWidth, 0, color );
} }
else else
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon, track->m_Width, color ); radius, track->m_Width, color );
}
} }
break; break;
...@@ -139,26 +141,33 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -139,26 +141,33 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
break; break;
case S_SPOT_CIRCLE: case S_SPOT_CIRCLE:
{
int radius = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
if( (rayon / zoom) < L_MIN_DESSIN ) if( (radius / zoom) < L_MIN_DESSIN )
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon, 0, color ); radius, 0, color );
} }
else if( fillopt == SKETCH ) else if( fillopt == SKETCH )
{ {
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon, 0, color ); radius, 0, color );
} }
else else
{ {
GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
rayon, 0, color, color ); radius, 0, color, color );
}
} }
break; break;
case S_SPOT_RECT: case S_SPOT_RECT:
case S_RECT: case S_RECT:
l_piste = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
if( (l_piste / zoom) < L_MIN_DESSIN ) if( (l_piste / zoom) < L_MIN_DESSIN )
{ {
...@@ -189,6 +198,8 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -189,6 +198,8 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
case S_SEGMENT: case S_SEGMENT:
l_piste = track->m_Width >> 1;
if( (l_piste / zoom) < L_MIN_DESSIN ) if( (l_piste / zoom) < L_MIN_DESSIN )
{ {
GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
......
...@@ -95,13 +95,57 @@ void GRMoveRel(int x, int y); ...@@ -95,13 +95,57 @@ void GRMoveRel(int x, int y);
void GRSMoveRel(int x, int y); void GRSMoveRel(int x, int y);
void GRLineRel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int width, int Color); void GRLineRel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int width, int Color);
void GRSLineRel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int width, int Color); void GRSLineRel(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int width, int Color);
void GRPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points,
bool Fill, int width, int Color, int BgColor);
void GRClosedPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, bool Fill, int Color, int BgColor); void GRPoly(EDA_Rect * ClipBox, wxDC * DC, int n, wxPoint Points[], bool Fill, int width, int Color, int BgColor);
void GRClosedPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, bool Fill, int width, int Color, int BgColor);
void GRSPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, bool Fill, int width, int Color, int BgColor);
void GRSClosedPoly(EDA_Rect * ClipBox, wxDC * DC, int n, int *Points, bool Fill, int width, int Color, int BgColor); /**
void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int Color); * Function GRClosedPoly
* draws a closed polygon onto the drawing context \a aDC and optionally fills and/or
* draws a border around it.
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
* @param aDC the device context into which drawing should occur.
* @param aPointCount the number of points in the array \a aPointArray.
* @param aPointArray an array holding the wxPoints in the polygon.
* @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
* @param aPenColor the color index of the border.
* @param aFillColor the fill color of the polygon's interior.
*/
void GRClosedPoly(EDA_Rect* ClipBox, wxDC* aDC, int aPointCount, wxPoint aPoints[], bool doFill, int aPenColor, int aFillColor);
// @todo could make these 2 closed polygons calls a single function and default the aPenWidth argument
/**
* Function GRClosedPoly
* draws a closed polygon onto the drawing context \a aDC and optionally fills and/or
* draws a border around it.
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
* @param aDC the device context into which drawing should occur.
* @param aPointCount the number of points in the array \a aPointArray.
* @param aPointArray an array holding the wxPoints in the polygon.
* @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
* @param aPenWidth is the width of the pen to use on the perimeter, can be zero.
* @param aPenColor the color index of the border.
* @param aFillColor the fill color of the polygon's interior.
*/
void GRClosedPoly(EDA_Rect * ClipBox, wxDC* aDC, int aPointCount, wxPoint aPoints[], bool doFill, int aPenWidth, int aPenColor, int aFillColor);
/**
* Function GRCircle
* draws a circle onto the drawing context \a aDC centered at the user coordinates (x,y)
*
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
* @param aDC the device context into which drawing should occur.
* @param x The x coordinate in user space of the center of the circle.
* @param x The y coordinate in user space of the center of the circle.
* @param aRadius is the radis of the circle.
* @param aColor is an index into our color table of RGB colors.
* @see EDA_Colors and colors.h
*/
void GRCircle(EDA_Rect * ClipBox, wxDC * aDC, int x, int y, int aRadius, int aColor);
void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int width, int Color); void GRCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, int width, int Color);
void GRFilledCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r, void GRFilledCircle(EDA_Rect * ClipBox, wxDC * DC, int x, int y, int r,
int width, int Color, int BgColor); int width, int Color, int BgColor);
......
...@@ -35,17 +35,11 @@ EDGE_MODULE::EDGE_MODULE( MODULE* parent ) : ...@@ -35,17 +35,11 @@ EDGE_MODULE::EDGE_MODULE( MODULE* parent ) :
m_Shape = S_SEGMENT; m_Shape = S_SEGMENT;
m_Angle = 0; m_Angle = 0;
m_Width = 120; m_Width = 120;
m_PolyCount = 0; // For polygons : number of points (> 2)
m_PolyList = NULL; // For polygons: coord list (1 point = 2 coord)
} }
EDGE_MODULE::~EDGE_MODULE() EDGE_MODULE::~EDGE_MODULE()
{ {
if( m_PolyList )
free( m_PolyList );
m_PolyList = NULL;
m_PolyCount = 0;
} }
...@@ -56,6 +50,7 @@ void EDGE_MODULE:: Copy( EDGE_MODULE* source ) // copy structure ...@@ -56,6 +50,7 @@ void EDGE_MODULE:: Copy( EDGE_MODULE* source ) // copy structure
if( source == NULL ) if( source == NULL )
return; return;
// @todo why not just use "*this = source;" ?
m_Start = source->m_Start; m_Start = source->m_Start;
m_End = source->m_End; m_End = source->m_End;
m_Shape = source->m_Shape; m_Shape = source->m_Shape;
...@@ -64,18 +59,8 @@ void EDGE_MODULE:: Copy( EDGE_MODULE* source ) // copy structure ...@@ -64,18 +59,8 @@ void EDGE_MODULE:: Copy( EDGE_MODULE* source ) // copy structure
m_Angle = source->m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres m_Angle = source->m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres
m_Layer = source->m_Layer; m_Layer = source->m_Layer;
m_Width = source->m_Width; m_Width = source->m_Width;
if( m_PolyList )
free( m_PolyList ); m_PolyPoints = source->m_PolyPoints;
m_PolyCount = 0;
m_PolyList = NULL;
if( source->m_PolyCount && source->m_PolyList )
{
int size;
m_PolyCount = source->m_PolyCount; // For polygons : number of points
size = m_PolyCount * 2 * sizeof(int); // For polygons: 1 point = 2 coord
m_PolyList = (int*) MyMalloc( size );
memcpy( m_PolyList, source->m_PolyList, size );
}
} }
/***********************************/ /***********************************/
...@@ -211,31 +196,30 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -211,31 +196,30 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
case S_POLYGON: case S_POLYGON:
{ {
// We must compute true coordinates from m_PolyList // We must compute true coordinates from m_PolyPoints
// which are relative to module position, orientation 0 // which are relative to module position, orientation 0
int ii, * source, * ptr, * ptr_base;
ptr = ptr_base = (int*) MyMalloc( 2 * m_PolyCount * sizeof(int) ); std::vector<wxPoint> points = m_PolyPoints;
source = m_PolyList;
for( ii = 0; ii < m_PolyCount; ii++ ) for( unsigned ii = 0; ii < points.size(); ii++ )
{ {
int x, y; wxPoint& pt = points[ii];
x = *source; source++; y = *source; source++;
if( Module ) if( Module )
{ {
RotatePoint( &x, &y, Module->m_Orient ); RotatePoint( &pt.x, &pt.y, Module->m_Orient );
x += Module->m_Pos.x; pt.x += Module->m_Pos.x;
y += Module->m_Pos.y; pt.y += Module->m_Pos.y;
} }
x += m_Start0.x - offset.x;
y += m_Start0.y - offset.y; pt.x += m_Start0.x - offset.x;
*ptr = x; ptr++; *ptr = y; ptr++; pt.y += m_Start0.y - offset.y;
} }
GRPoly( &panel->m_ClipBox, DC, m_PolyCount, ptr_base, GRPoly( &panel->m_ClipBox, DC, points.size(), &points[0],
TRUE, m_Width, color, color ); TRUE, m_Width, color, color );
free( ptr_base );
break;
} }
break;
} }
} }
...@@ -306,13 +290,11 @@ bool EDGE_MODULE::Save( FILE* aFile ) const ...@@ -306,13 +290,11 @@ bool EDGE_MODULE::Save( FILE* aFile ) const
ret = fprintf( aFile, "DP %d %d %d %d %d %d %d\n", ret = fprintf( aFile, "DP %d %d %d %d %d %d %d\n",
m_Start0.x, m_Start0.y, m_Start0.x, m_Start0.y,
m_End0.x, m_End0.y, m_End0.x, m_End0.y,
m_PolyCount, m_PolyPoints.size(),
m_Width, m_Layer ); m_Width, m_Layer );
int* pInt; for( unsigned i=0; i<m_PolyPoints.size(); ++i )
pInt = m_PolyList; fprintf( aFile, "Dl %d %d\n", m_PolyPoints[i].x, m_PolyPoints[i].y );
for( int i=0; i<m_PolyCount; ++i, pInt+=2 )
fprintf( aFile, "Dl %d %d\n", pInt[0], pInt[1] );
break; break;
default: default:
...@@ -345,11 +327,10 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, ...@@ -345,11 +327,10 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
* *
*/ */
{ {
int ii, * ptr; int ii;
int error = 0; int error = 0;
char Buf[1024]; char Buf[1024];
switch( Line[1] ) switch( Line[1] )
{ {
case 'S': case 'S':
...@@ -394,26 +375,37 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, ...@@ -394,26 +375,37 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
break; break;
case S_POLYGON: case S_POLYGON:
int pointCount;
sscanf( Line + 3, "%d %d %d %d %d %d %d", sscanf( Line + 3, "%d %d %d %d %d %d %d",
&m_Start0.x, &m_Start0.y, &m_Start0.x, &m_Start0.y,
&m_End0.x, &m_End0.y, &m_End0.x, &m_End0.y,
&m_PolyCount, &m_Width, &m_Layer ); &pointCount, &m_Width, &m_Layer );
(*LineNum)++; (*LineNum)++;
m_PolyList = (int*) MyZMalloc( 2 * m_PolyCount * sizeof(int) ); m_PolyPoints.clear();
for( ii = 0, ptr = m_PolyList; ii < m_PolyCount; ii++ ) m_PolyPoints.reserve( pointCount );
for( ii = 0; ii<pointCount; ii++ )
{ {
if( GetLine( File, Buf, LineNum, sizeof(Buf) - 1 ) != NULL ) if( GetLine( File, Buf, LineNum, sizeof(Buf) - 1 ) != NULL )
{ {
if( strncmp( Buf, "Dl", 2 ) != 0 ) if( strncmp( Buf, "Dl", 2 ) != 0 )
{ {
error = 1; break; error = 1;
break;
} }
sscanf( Buf + 3, "%d %d\n", ptr, ptr + 1 );
(*LineNum)++; ptr += 2; int x;
int y;
sscanf( Buf + 3, "%d %d\n", &x, &y );
m_PolyPoints.push_back( wxPoint(x,y) );
(*LineNum)++;
} }
else else
{ {
error = 1; break; error = 1;
break;
} }
} }
......
...@@ -20,8 +20,7 @@ public: ...@@ -20,8 +20,7 @@ public:
int m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres int m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres
int m_PolyCount; // For polygons: number of points (> 2) std::vector<wxPoint> m_PolyPoints; // For polygons: number of points (> 2)
int* m_PolyList; // For polygons: coord list (1 point = 2 coord)
// Coord are relative to Origin, orient 0 // Coord are relative to Origin, orient 0
public: public:
......
...@@ -280,7 +280,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -280,7 +280,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
coord[ii].y = coord[ii].y + uy0; coord[ii].y = coord[ii].y + uy0;
} }
GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, fillpad, color, color ); GRClosedPoly( &panel->m_ClipBox, DC, 4, coord, fillpad, color, color );
if( DisplayIsol ) if( DisplayIsol )
{ {
...@@ -306,7 +306,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -306,7 +306,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
coord[ii].y = coord[ii].y + uy0; coord[ii].y = coord[ii].y + uy0;
} }
GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color ); GRClosedPoly( &panel->m_ClipBox, DC, 4, coord, 0, color, color );
} }
} }
break; break;
......
...@@ -455,19 +455,6 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con ...@@ -455,19 +455,6 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con
} }
} }
/* this is local class to handle 2 integers that are a corner coordinate
* One could use wxPoint insteed.
* However, this class has only 2 integers
* if changes happen in wxPoint ( like virtual functions) they will be not suitable
* So i prefer use this simple class to handle a coordinate.
*/
class corner_coord
{
public:
int x;
int y;
};
/************************************************************************************/ /************************************************************************************/
void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
...@@ -483,8 +470,8 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, ...@@ -483,8 +470,8 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
* @param aDrawMode = GR_OR, GR_XOR, GR_COPY .. * @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
*/ */
{ {
static vector < char > CornersTypeBuffer; static vector <char> CornersTypeBuffer;
static vector < corner_coord > CornersBuffer; static vector <wxPoint> CornersBuffer;
// outline_mode is false to show filled polys, // outline_mode is false to show filled polys,
// and true to show polygons outlines only (test and debug purposes) // and true to show polygons outlines only (test and debug purposes)
bool outline_mode = DisplayOpt.DisplayZonesMode == 2 ? true : false; bool outline_mode = DisplayOpt.DisplayZonesMode == 2 ? true : false;
...@@ -535,13 +522,15 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, ...@@ -535,13 +522,15 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
for( int ic = 0; ic <= imax; ic++ ) for( int ic = 0; ic <= imax; ic++ )
{ {
CPolyPt* corner = &m_FilledPolysList[ic]; CPolyPt* corner = &m_FilledPolysList[ic];
corner_coord coord; wxPoint coord;
coord.x = corner->x + offset.x; coord.x = corner->x + offset.x;
coord.y = corner->y + offset.y; coord.y = corner->y + offset.y;
CornersBuffer.push_back(coord); CornersBuffer.push_back(coord);
CornersTypeBuffer.push_back((char) corner->utility); CornersTypeBuffer.push_back((char) corner->utility);
if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
{ /* Draw the current filled area: draw segments ouline first {
/* Draw the current filled area: draw segments ouline first
* Curiously, draw segments ouline first and after draw filled polygons * Curiously, draw segments ouline first and after draw filled polygons
* with oulines thickness = 0 is a faster than * with oulines thickness = 0 is a faster than
* just draw filled polygons but with oulines thickness = m_ZoneMinThickness * just draw filled polygons but with oulines thickness = m_ZoneMinThickness
...@@ -559,6 +548,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, ...@@ -559,6 +548,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
int y0 = CornersBuffer[is].y; int y0 = CornersBuffer[is].y;
int x1 = CornersBuffer[ie].x; int x1 = CornersBuffer[ie].x;
int y1 = CornersBuffer[ie].y; int y1 = CornersBuffer[ie].y;
if ( CornersTypeBuffer[ie] == 0 ) // Draw only basic outlines, not extra segments if ( CornersTypeBuffer[ie] == 0 ) // Draw only basic outlines, not extra segments
{ {
if( (!DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) ) if( (!DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) )
...@@ -574,7 +564,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, ...@@ -574,7 +564,7 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel,
} }
// Draw areas: // Draw areas:
if( (m_FillMode == 0 ) && ! outline_mode ) if( (m_FillMode == 0 ) && ! outline_mode )
GRPoly( &panel->m_ClipBox, DC, CornersBuffer.size(), (int*)&CornersBuffer[0].x, GRPoly( &panel->m_ClipBox, DC, CornersBuffer.size(), &CornersBuffer[0],
true, 0, color, color ); true, 0, color, color );
} }
CornersTypeBuffer.clear(); CornersTypeBuffer.clear();
......
...@@ -116,7 +116,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) ...@@ -116,7 +116,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
* the "gap" is isolation created between this 2 pads * the "gap" is isolation created between this 2 pads
*/ */
{ {
int gap_size, oX, ii; int oX;
float fcoeff; float fcoeff;
D_PAD* pad; D_PAD* pad;
MODULE* Module; MODULE* Module;
...@@ -126,7 +126,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) ...@@ -126,7 +126,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
bool abort; bool abort;
/* Enter the size of the gap or stub*/ /* Enter the size of the gap or stub*/
gap_size = g_DesignSettings.m_CurrentTrackWidth; // Valeur raisonnable int gap_size = g_DesignSettings.m_CurrentTrackWidth; // Valeur raisonnable
switch( shape_type ) switch( shape_type )
{ {
...@@ -219,40 +219,39 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type ) ...@@ -219,40 +219,39 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
pad->m_Pos.y += pad->m_Pos0.y; pad->m_Pos.y += pad->m_Pos0.y;
break; break;
case 2: //Arc Stub created by a polygonal approach: case 2: // Arc Stub created by a polygonal approach:
{ {
EDGE_MODULE* edge; int* ptr, theta; EDGE_MODULE* edge = new EDGE_MODULE( Module );
ii = angle / 50; // Note : angles are in 0.1 degrees
edge = new EDGE_MODULE( Module );
Module->m_Drawings.PushFront( edge ); Module->m_Drawings.PushFront( edge );
edge->m_Shape = S_POLYGON; edge->m_Shape = S_POLYGON;
edge->SetLayer( LAYER_CMP_N ); edge->SetLayer( LAYER_CMP_N );
edge->m_PolyCount = ii + 3;
edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) ); int numPoints = angle / 50 + 3; // Note : angles are in 0.1 degrees
ptr = edge->m_PolyList; edge->m_PolyPoints.reserve( numPoints );
edge->m_Start0.y = -pad->m_Size.y / 2; edge->m_Start0.y = -pad->m_Size.y / 2;
*ptr = 0; ptr++; edge->m_PolyPoints.push_back( wxPoint(0,0) );
*ptr = 0; ptr++;
theta = -angle / 2; int theta = -angle / 2;
for( ii = 1; ii < edge->m_PolyCount - 1; ii++ ) for( int ii=1; ii<numPoints-1; ii++ )
{ {
int x, y; wxPoint pt(0, -gap_size);
x = 0; y = -gap_size;
RotatePoint( &x, &y, theta ); RotatePoint( &pt.x, &pt.y, theta );
*ptr = x; ptr++; *ptr = y; ptr++;
edge->m_PolyPoints.push_back( pt );
theta += 50; theta += 50;
if( theta > angle / 2 ) if( theta > angle / 2 )
theta = angle / 2; theta = angle / 2;
} }
// Close the polygon: // Close the polygon:
*ptr = edge->m_PolyList[0]; ptr++; edge->m_PolyPoints.push_back( edge->m_PolyPoints[0] );
*ptr = edge->m_PolyList[1];
break;
} }
break;
default: default:
break; break;
...@@ -505,11 +504,13 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( ) ...@@ -505,11 +504,13 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( )
MODULE* Module; MODULE* Module;
wxString cmp_name; wxString cmp_name;
int pad_count = 2; int pad_count = 2;
EDGE_MODULE* edge; int* ptr; EDGE_MODULE* edge;
int ii, npoints; int ii, npoints;
WinEDA_SetParamShapeFrame* frame = new WinEDA_SetParamShapeFrame( this, wxPoint( -1, -1 ) ); WinEDA_SetParamShapeFrame* frame = new WinEDA_SetParamShapeFrame( this, wxPoint( -1, -1 ) );
int ok = frame->ShowModal(); frame->Destroy();
int ok = frame->ShowModal();
frame->Destroy();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
...@@ -524,6 +525,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( ) ...@@ -524,6 +525,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( )
if( PolyShapeType == 2 ) // mirrored if( PolyShapeType == 2 ) // mirrored
ShapeScaleY = -ShapeScaleY; ShapeScaleY = -ShapeScaleY;
ShapeSize.x = (int) round( ShapeScaleX ); ShapeSize.x = (int) round( ShapeScaleX );
ShapeSize.y = (int) round( ShapeScaleY ); ShapeSize.y = (int) round( ShapeScaleY );
...@@ -558,69 +560,50 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( ) ...@@ -558,69 +560,50 @@ MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( )
edge->SetLayer( LAYER_CMP_N ); edge->SetLayer( LAYER_CMP_N );
npoints = PolyEdgesCount; npoints = PolyEdgesCount;
switch( PolyShapeType ) edge->m_PolyPoints.reserve(2 * PolyEdgesCount + 2);
{
case 0: // Single
case 2: // Single, mirrored
edge->m_PolyCount = PolyEdgesCount + 2;
break;
case 1: // Symetric
edge->m_PolyCount = (2 * PolyEdgesCount) + 2;
break;
}
edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) );
ptr = edge->m_PolyList;
// Init start point coord: // Init start point coord:
*ptr = pad1->m_Pos0.x; ptr++; edge->m_PolyPoints.push_back( wxPoint( pad1->m_Pos0.x, 0) );
*ptr = 0; ptr++;
double* dptr = PolyEdges; double* dptr = PolyEdges;
wxPoint first_cordinate, last_cordinate; wxPoint first_coordinate, last_coordinate;
for( ii = 0; ii < npoints; ii++ ) // Copy points for( ii = 0; ii < npoints; ii++ ) // Copy points
{ {
last_cordinate.x = *ptr = (int) round( *dptr * ShapeScaleX ) + pad1->m_Pos0.x; last_coordinate.x = (int) round( *dptr++ * ShapeScaleX ) + pad1->m_Pos0.x;
dptr++; ptr++; last_coordinate.y = -(int) round( *dptr++ * ShapeScaleY );
last_cordinate.y = *ptr = -(int) round( *dptr * ShapeScaleY ); edge->m_PolyPoints.push_back( last_coordinate );
dptr++; ptr++;
} }
first_cordinate.y = edge->m_PolyList[3]; first_coordinate.y = edge->m_PolyPoints[1].y;
switch( PolyShapeType ) switch( PolyShapeType )
{ {
int* ptr1;
case 0: // Single case 0: // Single
case 2: // Single mirrored case 2: // Single mirrored
// Init end point coord: // Init end point coord:
*ptr = pad2->m_Pos0.x = last_cordinate.x; ptr++; pad2->m_Pos0.x = last_coordinate.x;
*ptr = 0; edge->m_PolyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
pad1->m_Size.x = pad1->m_Size.y = ABS( first_cordinate.y );
pad2->m_Size.x = pad2->m_Size.y = ABS( last_cordinate.y ); pad1->m_Size.x = pad1->m_Size.y = ABS( first_coordinate.y );
pad1->m_Pos0.y = first_cordinate.y / 2; pad2->m_Size.x = pad2->m_Size.y = ABS( last_coordinate.y );
pad2->m_Pos0.y = last_cordinate.y / 2; pad1->m_Pos0.y = first_coordinate.y / 2;
pad2->m_Pos0.y = last_coordinate.y / 2;
pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y; pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y;
pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y; pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y;
break; break;
case 1: // Symetric case 1: // Symetric
ptr1 = ptr - 2; for( int ndx = edge->m_PolyPoints.size()-1; ndx>=0; --ndx )
for( ii = 0; ii <= npoints; ii++ )
{ {
*ptr = *ptr1; // Copy X coord wxPoint pt = edge->m_PolyPoints[ndx];
ptr++;
*ptr = -*(ptr1 + 1); // Copy Y coord, mirror X axis
ptr1 -= 2; ptr++;
}
pad1->m_Size.x = pad1->m_Size.y = 2* ABS( first_cordinate.y ); pt.y = -pt.y; // mirror about X axis
pad2->m_Size.x = pad2->m_Size.y = 2* ABS( last_cordinate.y ); edge->m_PolyPoints.push_back( pt );
}
pad1->m_Size.x = pad1->m_Size.y = 2 * ABS( first_coordinate.y );
pad2->m_Size.x = pad2->m_Size.y = 2 * ABS( last_coordinate.y );
break; break;
} }
......
...@@ -472,6 +472,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -472,6 +472,7 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
if( PtEdge->Type() != TYPE_EDGE_MODULE ) if( PtEdge->Type() != TYPE_EDGE_MODULE )
return; return;
type_trace = PtEdge->m_Shape; type_trace = PtEdge->m_Shape;
thickness = PtEdge->m_Width; thickness = PtEdge->m_Width;
if( Plot_Mode == FILAIRE ) if( Plot_Mode == FILAIRE )
...@@ -520,13 +521,16 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -520,13 +521,16 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
{ {
// We must compute true coordinates from m_PolyList // We must compute true coordinates from m_PolyList
// which are relative to module position, orientation 0 // which are relative to module position, orientation 0
int ii, * source, * ptr, * ptr_base;
MODULE* Module = NULL; MODULE* Module = NULL;
if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) ) if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) )
Module = (MODULE*) PtEdge->GetParent(); Module = (MODULE*) PtEdge->GetParent();
ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) );
source = PtEdge->m_PolyList; int* ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyPoints.size() * sizeof(int) );
for( ii = 0; ii < PtEdge->m_PolyCount; ii++ ) int* ptr = ptr_base;
int* source = (int*) &PtEdge->m_PolyPoints[0];
for( unsigned ii = 0; ii < PtEdge->m_PolyPoints.size(); ii++ )
{ {
int x = *source++; int x = *source++;
int y = *source++; int y = *source++;
...@@ -545,10 +549,10 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -545,10 +549,10 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
*ptr++ = y; *ptr++ = y;
} }
PlotFilledPolygon( format_plot, PtEdge->m_PolyCount, ptr_base ); PlotFilledPolygon( format_plot, PtEdge->m_PolyPoints.size(), ptr_base );
free( ptr_base ); free( ptr_base );
break;
} }
break;
} }
} }
......
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