Commit 0d790e57 authored by dickelbeck's avatar dickelbeck

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

parent fadacffc
...@@ -5,18 +5,29 @@ Started 2007-June-11 ...@@ -5,18 +5,29 @@ 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>
================================================================================ ================================================================================
++Eeschema: ++Eeschema:
More about italic and bold texts options in fields and graphic texts More about italic and bold texts options in fields and graphic texts
2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
++Pcbnew: ++Pcbnew:
Added dialog box to edit graphic items (graphic segments, circles, arcs) Added dialog box to edit graphic items (graphic segments, circles, arcs)
properties properties
2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
...@@ -24,7 +35,7 @@ email address. ...@@ -24,7 +35,7 @@ email address.
++All ++All
Cleaning code to draw/plot texts: Cleaning code to draw/plot texts:
Now only one function is used to draw and plot texts in pcbnew in all formats Now only one function is used to draw and plot texts in pcbnew in all formats
Italics texts are allowed in pcbnew (work in progress) Italics texts are allowed in pcbnew (work in progress)
2008-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Dec-14 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,19 +35,20 @@ ...@@ -35,19 +35,20 @@
/*******************************************************************/ /*******************************************************************/
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 )
/*******************************************************************/ /*******************************************************************/
{ {
wxASSERT( parent ); wxASSERT( parent );
wxASSERT( Pnext == NULL ); wxASSERT( Pnext == NULL );
m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL;
m_Pos = pos; m_Pos = pos;
m_Edge = 0; m_Edge = 0;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = TRUE;
m_Number = 2; m_Number = 2;
} }
...@@ -58,8 +59,8 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy() ...@@ -58,8 +59,8 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
Hierarchical_PIN_Sheet_Struct* newitem = Hierarchical_PIN_Sheet_Struct* newitem =
new Hierarchical_PIN_Sheet_Struct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text ); new Hierarchical_PIN_Sheet_Struct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text );
newitem->m_Edge = m_Edge; newitem->m_Edge = m_Edge;
newitem->m_Shape = m_Shape; newitem->m_Shape = m_Shape;
newitem->m_Number = m_Number; newitem->m_Number = m_Number;
return newitem; return newitem;
...@@ -68,24 +69,31 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy() ...@@ -68,24 +69,31 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
/********************************************************************************************/ /********************************************************************************************/
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color ) int DrawMode, int Color )
/********************************************************************************************/ /********************************************************************************************/
/* Routine de dessin des Labels type hierarchie */ /* Routine de dessin des Labels type hierarchie */
{ {
GRTextHorizJustifyType side; GRTextHorizJustifyType side;
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 )
...@@ -99,8 +107,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -99,8 +107,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
side = GR_TEXT_HJUSTIFY_LEFT; side = GR_TEXT_HJUSTIFY_LEFT;
} }
DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor, DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor,
m_Text, TEXT_ORIENT_HORIZ, size, m_Text, TEXT_ORIENT_HORIZ, size,
side, GR_TEXT_VJUSTIFY_CENTER, LineWidth ); side, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
} }
/* dessin du symbole de connexion */ /* dessin du symbole de connexion */
...@@ -110,8 +118,11 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -110,8 +118,11 @@ 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;
NbSegm = 0; coord[1] = posy;
size2 = size.x / 2;
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 */
} }
...@@ -192,9 +204,9 @@ bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const ...@@ -192,9 +204,9 @@ bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const
} }
if( fprintf( aFile, "F%d \"%s\" %c %c %-3d %-3d %-3d\n", m_Number, if( fprintf( aFile, "F%d \"%s\" %c %c %-3d %-3d %-3d\n", m_Number,
CONV_TO_UTF8( m_Text ), type, side, CONV_TO_UTF8( m_Text ), type, side,
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y,
m_Size.x ) == EOF ) m_Size.x ) == EOF )
{ {
return false; return false;
} }
...@@ -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 )
{ {
...@@ -209,12 +222,12 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os ) ...@@ -209,12 +222,12 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os )
wxString s = GetClass(); wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
<< " pin_name=\"" << CONV_TO_UTF8( m_Text ) << '"' << " pin_name=\"" << CONV_TO_UTF8( m_Text ) << '"'
<< "/>\n" << "/>\n"
<< 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 );
} }
......
This diff is collapsed.
...@@ -28,37 +28,37 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl ...@@ -28,37 +28,37 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
/* Draw gerbview layers, for printing /* Draw gerbview layers, for printing
*/ */
{ {
DISPLAY_OPTIONS save_opt; DISPLAY_OPTIONS save_opt;
int DisplayPolygonsModeImg; int DisplayPolygonsModeImg;
save_opt = DisplayOpt; save_opt = DisplayOpt;
if( printmasklayer & ALL_CU_LAYERS ) if( printmasklayer & ALL_CU_LAYERS )
DisplayOpt.DisplayPadFill = FILLED; DisplayOpt.DisplayPadFill = FILLED;
else else
DisplayOpt.DisplayPadFill = SKETCH; DisplayOpt.DisplayPadFill = SKETCH;
DisplayOpt.DisplayPadNum = 0; DisplayOpt.DisplayPadNum = 0;
DisplayOpt.DisplayPadNoConn = 0; DisplayOpt.DisplayPadNoConn = 0;
DisplayOpt.DisplayPadIsol = 0; DisplayOpt.DisplayPadIsol = 0;
DisplayOpt.DisplayModEdge = FILLED; DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayModText = FILLED; DisplayOpt.DisplayModText = FILLED;
DisplayOpt.DisplayPcbTrackFill = FILLED; DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.DisplayTrackIsol = 0; DisplayOpt.DisplayTrackIsol = 0;
DisplayOpt.DisplayDrawItems = FILLED; DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZonesMode = 0; DisplayOpt.DisplayZonesMode = 0;
DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch; DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch;
g_DisplayPolygonsModeSketch = 0; g_DisplayPolygonsModeSketch = 0;
m_PrintIsMirrored = aPrintMirrorMode; m_PrintIsMirrored = aPrintMirrorMode;
( (WinEDA_GerberFrame*) m_Parent )->Trace_Gerber( DC, GR_COPY, printmasklayer ); ( (WinEDA_GerberFrame*) m_Parent )->Trace_Gerber( DC, GR_COPY, printmasklayer );
if( Print_Sheet_Ref ) if( Print_Sheet_Ref )
m_Parent->TraceWorkSheet( DC, GetScreen(), 0 ); m_Parent->TraceWorkSheet( DC, GetScreen(), 0 );
m_PrintIsMirrored = false; m_PrintIsMirrored = false;
DisplayOpt = save_opt; DisplayOpt = save_opt;
g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg; g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg;
} }
...@@ -69,31 +69,31 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -69,31 +69,31 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/* Trace le PCB, et les elements complementaires ( axes, grille .. ) /* Trace le PCB, et les elements complementaires ( axes, grille .. )
*/ */
{ {
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
if( !m_Pcb ) if( !m_Pcb )
return; return;
ActiveScreen = screen; ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
if( EraseBg ) if( EraseBg )
DrawPanel->EraseScreen( DC ); DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
Trace_Gerber( DC, GR_COPY, -1 ); Trace_Gerber( DC, GR_COPY, -1 );
TraceWorkSheet( DC, screen, 0 ); TraceWorkSheet( DC, screen, 0 );
Affiche_Status_Box(); Affiche_Status_Box();
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->Trace_Curseur( DC ); DrawPanel->Trace_Curseur( DC );
} }
/********************************************************************/ /********************************************************************/
void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset ) int aDrawMode, const wxPoint& offset )
/********************************************************************/ /********************************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */ /* Redraw the BOARD items but not cursors, axis or grid */
// @todo: replace WinEDA_GerberFrame::Trace_Gerber() by this function // @todo: replace WinEDA_GerberFrame::Trace_Gerber() by this function
...@@ -110,72 +110,72 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay ...@@ -110,72 +110,72 @@ void WinEDA_GerberFrame::Trace_Gerber( wxDC* DC, int draw_mode, int printmasklay
* @param printmasklayer = mask for allowed layer (=-1 to draw all layers) * @param printmasklayer = mask for allowed layer (=-1 to draw all layers)
*/ */
{ {
if( !m_Pcb ) if( !m_Pcb )
return; return;
// Draw filled polygons bool erase;
#define NBMAX 20000
int nbpoints = 0; // Draw filled polygons
int nbpointsmax = NBMAX; std::vector<wxPoint> coords;
int* coord = (int*) malloc( nbpointsmax * sizeof(int) * 2 );
int* ptcoord = coord; // minimize reallocations of the vector's internal array by starting with a good sized one.
coords.reserve(20000);
for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
{ for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
if( !(track->ReturnMaskLayer() & printmasklayer) ) {
continue; if( !(track->ReturnMaskLayer() & printmasklayer) )
continue;
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 filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0; int Color;
int filled;
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord,
filled, Color, Color ); if( erase )
} {
D(printf("erase\n");)
nbpoints = 2; Color = g_DrawBgColor;
ptcoord = coord; filled = true;
}
*ptcoord++ = track->m_Start.x; else
*ptcoord++ = track->m_Start.y; {
D(printf("NO erase\n");)
*ptcoord++ = track->m_End.x; Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
*ptcoord++ = track->m_End.y; filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
} }
else
{ GRClosedPoly( &DrawPanel->m_ClipBox, DC, coords.size(), &coords[0],
if( nbpoints >= nbpointsmax ) filled, Color, Color );
{ }
nbpointsmax *= 2;
coord = (int*) realloc( coord, nbpointsmax * sizeof(int) * 2 ); erase = ( track->m_Flags & DRAW_ERASED ) ? true : false;
ptcoord = coord + nbpointsmax;
} coords.clear();
nbpoints++; coords.push_back( track->m_Start );
coords.push_back( track->m_End );
*ptcoord++ = track->m_End.x; }
*ptcoord++ = track->m_End.y; else
} {
coords.push_back( track->m_End );
if( track->Next() == NULL ) // Last point }
{
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()]; if( track->Next() == NULL ) // Last point
int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0; {
int Color = g_DesignSettings.m_LayerColor[track->GetLayer()];
GRClosedPoly( &DrawPanel->m_ClipBox, DC, nbpoints, coord, int filled = (g_DisplayPolygonsModeSketch == 0) ? 1 : 0;
filled, Color, Color );
} GRClosedPoly( &DrawPanel->m_ClipBox, DC, coords.size(), &coords[0],
} 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 );
if( DisplayOpt.DisplayPadNum ) if( DisplayOpt.DisplayPadNum )
Affiche_DCodes_Pistes( DrawPanel, DC, m_Pcb, GR_COPY ); Affiche_DCodes_Pistes( DrawPanel, DC, m_Pcb, GR_COPY );
GetScreen()->ClrRefreshReq(); GetScreen()->ClrRefreshReq();
} }
This diff is collapsed.
...@@ -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 );
}
} }
/***********************************/ /***********************************/
...@@ -210,33 +195,32 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -210,33 +195,32 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
break; break;
case S_POLYGON: case S_POLYGON:
{
// We must compute true coordinates from m_PolyList
// which are relative to module position, orientation 0
int ii, * source, * ptr, * ptr_base;
ptr = ptr_base = (int*) MyMalloc( 2 * m_PolyCount * sizeof(int) );
source = m_PolyList;
for( ii = 0; ii < m_PolyCount; ii++ )
{ {
int x, y; // We must compute true coordinates from m_PolyPoints
x = *source; source++; y = *source; source++; // which are relative to module position, orientation 0
if( Module )
std::vector<wxPoint> points = m_PolyPoints;
for( unsigned ii = 0; ii < points.size(); ii++ )
{ {
RotatePoint( &x, &y, Module->m_Orient ); wxPoint& pt = points[ii];
x += Module->m_Pos.x;
y += Module->m_Pos.y; if( Module )
{
RotatePoint( &pt.x, &pt.y, Module->m_Orient );
pt.x += Module->m_Pos.x;
pt.y += Module->m_Pos.y;
}
pt.x += m_Start0.x - offset.x;
pt.y += m_Start0.y - offset.y;
} }
x += m_Start0.x - offset.x;
y += m_Start0.y - offset.y;
*ptr = x; ptr++; *ptr = y; ptr++;
}
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,19 +522,21 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, ...@@ -535,19 +522,21 @@ 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 {
* Curiously, draw segments ouline first and after draw filled polygons /* Draw the current filled area: draw segments ouline first
* with oulines thickness = 0 is a faster than * Curiously, draw segments ouline first and after draw filled polygons
* just draw filled polygons but with oulines thickness = m_ZoneMinThickness * with oulines thickness = 0 is a faster than
* So DO NOT use draw filled polygons with oulines having a thickness > 0 * just draw filled polygons but with oulines thickness = m_ZoneMinThickness
* Note: Extra segments ( added by kbool to joint holes with external outline) are not drawn * So DO NOT use draw filled polygons with oulines having a thickness > 0
*/ * Note: Extra segments ( added by kbool to joint holes with external outline) are not drawn
*/
{ {
// Draw outlines: // Draw outlines:
if ( (m_ZoneMinThickness > 1) || outline_mode ) if ( (m_ZoneMinThickness > 1) || outline_mode )
...@@ -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 ) )
...@@ -573,12 +563,12 @@ void ZONE_CONTAINER::DrawFilledArea( WinEDA_DrawPanel* panel, ...@@ -573,12 +563,12 @@ 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();
CornersBuffer.clear(); CornersBuffer.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;
ii = angle / 50; // Note : angles are in 0.1 degrees
edge = new EDGE_MODULE( Module );
Module->m_Drawings.PushFront( edge );
edge->m_Shape = S_POLYGON;
edge->SetLayer( LAYER_CMP_N );
edge->m_PolyCount = ii + 3;
edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) );
ptr = edge->m_PolyList;
edge->m_Start0.y = -pad->m_Size.y / 2;
*ptr = 0; ptr++;
*ptr = 0; ptr++;
theta = -angle / 2;
for( ii = 1; ii < edge->m_PolyCount - 1; ii++ )
{ {
int x, y; EDGE_MODULE* edge = new EDGE_MODULE( Module );
x = 0; y = -gap_size; Module->m_Drawings.PushFront( edge );
RotatePoint( &x, &y, theta );
*ptr = x; ptr++; *ptr = y; ptr++; edge->m_Shape = S_POLYGON;
theta += 50; edge->SetLayer( LAYER_CMP_N );
if( theta > angle / 2 )
theta = angle / 2; int numPoints = angle / 50 + 3; // Note : angles are in 0.1 degrees
} edge->m_PolyPoints.reserve( numPoints );
edge->m_Start0.y = -pad->m_Size.y / 2;
edge->m_PolyPoints.push_back( wxPoint(0,0) );
int theta = -angle / 2;
for( int ii=1; ii<numPoints-1; ii++ )
{
wxPoint pt(0, -gap_size);
// Close the polygon: RotatePoint( &pt.x, &pt.y, theta );
*ptr = edge->m_PolyList[0]; ptr++;
*ptr = edge->m_PolyList[1]; edge->m_PolyPoints.push_back( pt );
theta += 50;
if( theta > angle / 2 )
theta = angle / 2;
}
// Close the polygon:
edge->m_PolyPoints.push_back( edge->m_PolyPoints[0] );
}
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;
} }
......
...@@ -325,9 +325,9 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot ) ...@@ -325,9 +325,9 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot )
size.x = -size.x; // Text is mirrored size.x = -size.x; // Text is mirrored
if ( format_plot == PLOT_FORMAT_GERBER ) if ( format_plot == PLOT_FORMAT_GERBER )
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw(thickness);
PlotGraphicText( format_plot, pos, BLACK, PlotGraphicText( format_plot, pos, BLACK,
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
...@@ -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 )
...@@ -517,39 +518,42 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge ) ...@@ -517,39 +518,42 @@ void Plot_1_EdgeModule( int format_plot, EDGE_MODULE* PtEdge )
break; break;
case S_POLYGON: case S_POLYGON:
{
// We must compute true coordinates from m_PolyList
// which are relative to module position, orientation 0
int ii, * source, * ptr, * ptr_base;
MODULE* Module = NULL;
if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) )
Module = (MODULE*) PtEdge->GetParent();
ptr = ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyCount * sizeof(int) );
source = PtEdge->m_PolyList;
for( ii = 0; ii < PtEdge->m_PolyCount; ii++ )
{ {
int x = *source++; // We must compute true coordinates from m_PolyList
int y = *source++; // which are relative to module position, orientation 0
MODULE* Module = NULL;
if( PtEdge->GetParent() && (PtEdge->GetParent()->Type() == TYPE_MODULE) )
Module = (MODULE*) PtEdge->GetParent();
int* ptr_base = (int*) MyMalloc( 2 * PtEdge->m_PolyPoints.size() * sizeof(int) );
int* ptr = ptr_base;
if( Module ) int* source = (int*) &PtEdge->m_PolyPoints[0];
for( unsigned ii = 0; ii < PtEdge->m_PolyPoints.size(); ii++ )
{ {
RotatePoint( &x, &y, Module->m_Orient ); int x = *source++;
x += Module->m_Pos.x; int y = *source++;
y += Module->m_Pos.y;
} if( Module )
{
RotatePoint( &x, &y, Module->m_Orient );
x += Module->m_Pos.x;
y += Module->m_Pos.y;
}
x += PtEdge->m_Start0.x; x += PtEdge->m_Start0.x;
y += PtEdge->m_Start0.y; y += PtEdge->m_Start0.y;
*ptr++ = x; *ptr++ = x;
*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;
} }
}
} }
...@@ -577,9 +581,9 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ) ...@@ -577,9 +581,9 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
size.x = -size.x; size.x = -size.x;
if ( format_plot == PLOT_FORMAT_GERBER ) if ( format_plot == PLOT_FORMAT_GERBER )
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw(thickness);
PlotGraphicText( format_plot, pos, BLACK, PlotGraphicText( format_plot, pos, BLACK,
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
...@@ -711,7 +715,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius ) ...@@ -711,7 +715,7 @@ void PlotCircle( int format_plot, int thickness, wxPoint centre, int radius )
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw(thickness);
PlotCircle_GERBER( centre, radius, thickness ); PlotCircle_GERBER( centre, radius, thickness );
break; break;
...@@ -755,7 +759,7 @@ void PlotPolygon( int format_plot, int nbpoints, int* coord, int width ) ...@@ -755,7 +759,7 @@ void PlotPolygon( int format_plot, int nbpoints, int* coord, int width )
switch( format_plot ) switch( format_plot )
{ {
case PLOT_FORMAT_GERBER: case PLOT_FORMAT_GERBER:
SelectD_CODE_For_LineDraw(width); SelectD_CODE_For_LineDraw(width);
PlotPolygon_GERBER( nbpoints, coord, width ); PlotPolygon_GERBER( nbpoints, coord, width );
break; break;
...@@ -812,7 +816,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle, ...@@ -812,7 +816,7 @@ void PlotArc( int format_plot, wxPoint centre, int start_angle, int end_angle,
RotatePoint( &ox, &oy, start_angle ); RotatePoint( &ox, &oy, start_angle );
if ( format_plot == PLOT_FORMAT_GERBER ) if ( format_plot == PLOT_FORMAT_GERBER )
SelectD_CODE_For_LineDraw(thickness); SelectD_CODE_For_LineDraw(thickness);
delta = 120; /* un cercle sera trace en 3600/delta = 30 segments / cercle*/ delta = 120; /* un cercle sera trace en 3600/delta = 30 segments / cercle*/
for( ii = start_angle + delta; ii < end_angle; ii += delta ) for( ii = start_angle + delta; ii < end_angle; ii += delta )
......
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