From 6b05cf315f32b477f474bc941a2914f704bfd162 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 13 Oct 2010 21:50:23 +0200 Subject: [PATCH] Fixed bug in GRLineArray(). Cleanup Gerbview code --- common/gr_basic.cpp | 287 +++++++++++++++++------------------ gerbview/edit.cpp | 32 +--- gerbview/gerberframe.cpp | 2 +- gerbview/toolbars_gerber.cpp | 7 - include/gr_basic.h | 15 +- pcbnew/class_zone.cpp | 27 ++-- 6 files changed, 168 insertions(+), 202 deletions(-) diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 3a2945ec9f..6f82c4e207 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -56,7 +56,7 @@ int g_DrawBgColor = WHITE; #define USE_CLIP_FILLED_POLYGONS #ifdef USE_CLIP_FILLED_POLYGONS -void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n ); +void ClipAndDrawFilledPoly( EDA_Rect * ClipBox, wxDC * DC, wxPoint Points[], int n ); #endif /* These functions are used by corresponding functions @@ -82,8 +82,9 @@ static void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle int EndAngle, int r, int width, int Color, int BgColor ); static void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int aPenSize, int Color ); -static void GRSLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[], - int lines, int width, int Color ); + +static void GRSLineArray( EDA_Rect * aClipBox, wxDC * aDC, std::vector& aLines, + int aWidth, int aColor ); /**/ extern BASE_SCREEN* ActiveScreen; @@ -91,18 +92,18 @@ extern BASE_SCREEN* ActiveScreen; static int GRLastMoveToX, GRLastMoveToY; static bool s_ForceBlackPen; /* if true: draws in black instead of - * color for printing. */ + * color for printing. */ static int xcliplo = 0, ycliplo = 0, xcliphi = 2000, ycliphi = 2000; -static int s_DC_lastcolor = -1; -static int s_DC_lastwidth = -1; +static int s_DC_lastcolor = -1; +static int s_DC_lastwidth = -1; static int s_DC_lastpenstyle = -1; static int s_DC_lastbrushcolor = -1; static int s_DC_lastbrushfill = -1; -static wxDC* s_DC_lastDC = NULL; +static wxDC* s_DC_lastDC = NULL; /* Local functions: */ @@ -169,7 +170,9 @@ int GRMapY( int y ) #if defined( USE_WX_ZOOM ) + // currently only used if USE_WX_ZOOM is defined. + /** * Test if any part of a line falls within the bounds of a rectangle. * @@ -189,14 +192,14 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) return false; wxRect rect = *aClipBox; - int minX = rect.GetLeft(); - int maxX = rect.GetRight(); - int minY = rect.GetTop(); - int maxY = rect.GetBottom(); - int clippedX, clippedY; + int minX = rect.GetLeft(); + int maxX = rect.GetRight(); + int minY = rect.GetTop(); + int maxY = rect.GetBottom(); + int clippedX, clippedY; #if DEBUG_DUMP_CLIP_COORDS - int tmpX1, tmpY1, tmpX2, tmpY2; + int tmpX1, tmpY1, tmpX2, tmpY2; tmpX1 = x1; tmpY1 = y1; tmpX2 = x2; @@ -236,14 +239,14 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) /* If we're here, it's a diagonal line. */ - if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY, - &clippedX, &clippedY ) /* Left */ - || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY, - &clippedX, &clippedY ) /* Top */ - || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY, - &clippedX, &clippedY ) /* Right */ - || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY, - &clippedX, &clippedY ) ) /* Bottom */ + if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY, + &clippedX, &clippedY ) /* Left */ + || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY, + &clippedX, &clippedY ) /* Top */ + || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY, + &clippedX, &clippedY ) /* Right */ + || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY, + &clippedX, &clippedY ) ) /* Bottom */ { if( x2 != clippedX ) x2 = clippedX; @@ -254,7 +257,8 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) /* If we're here, something has gone terribly wrong. */ #if DEBUG_DUMP_CLIP_ERROR_COORDS - wxLogDebug( wxT( "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ), + wxLogDebug( wxT( + "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ), tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 ); #endif return false; @@ -290,14 +294,14 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) } } - if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY, - &clippedX, &clippedY ) /* Left */ - || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY, - &clippedX, &clippedY ) /* Top */ - || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY, - &clippedX, &clippedY ) /* Right */ - || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY, - &clippedX, &clippedY ) ) /* Bottom */ + if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY, + &clippedX, &clippedY ) /* Left */ + || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY, + &clippedX, &clippedY ) /* Top */ + || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY, + &clippedX, &clippedY ) /* Right */ + || TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY, + &clippedX, &clippedY ) ) /* Bottom */ { if( x1 != clippedX ) x1 = clippedX; @@ -308,7 +312,8 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) /* If we're here, something has gone terribly wrong. */ #if DEBUG_DUMP_CLIP_ERROR_COORDS - wxLogDebug( wxT( "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ), + wxLogDebug( wxT( + "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ), tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 ); #endif return false; @@ -317,7 +322,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) { int* intersectX; int* intersectY; - int intersectX1, intersectY1, intersectX2, intersectY2; + int intersectX1, intersectY1, intersectX2, intersectY2; bool haveFirstPoint = false; intersectX = &intersectX1; @@ -327,8 +332,8 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY, intersectX, intersectY ) ) { - intersectX = &intersectX2; - intersectY = &intersectY2; + intersectX = &intersectX2; + intersectY = &intersectY2; haveFirstPoint = true; } @@ -386,7 +391,8 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) * something has gone terribly wrong. */ #if DEBUG_DUMP_CLIP_ERROR_COORDS if( haveFirstPoint ) - wxLogDebug( wxT( "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ), + wxLogDebug( wxT( + "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ), tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 ); #endif } @@ -400,6 +406,8 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) return true; } + + #endif // if defined( USE_WX_ZOOM ) @@ -528,10 +536,11 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC, ycliphi += width; #if defined( USE_WX_ZOOM ) - if ( clipLine( ClipBox, x1, y1, x2, y2 ) ) + if( clipLine( ClipBox, x1, y1, x2, y2 ) ) #else if( clip_line( x1, y1, x2, y2 ) ) #endif + return; } @@ -548,7 +557,7 @@ void GRResetPenAndBrush( wxDC* DC ) GRSetBrush( DC, BLACK ); // Force no fill s_DC_lastbrushcolor = -1; s_DC_lastcolor = -1; - s_DC_lastDC = NULL; + s_DC_lastDC = NULL; } @@ -566,10 +575,10 @@ void GRSetColorPen( wxDC* DC, int Color, int width, wxPenStyle style ) Color = BLACK; } - if( s_DC_lastcolor != Color || - s_DC_lastwidth != width || - s_DC_lastpenstyle != style || - s_DC_lastDC != DC ) + if( s_DC_lastcolor != Color + || s_DC_lastwidth != width + || s_DC_lastpenstyle != style + || s_DC_lastDC != DC ) { wxPen pen; @@ -584,8 +593,7 @@ void GRSetColorPen( wxDC* DC, int Color, int width, wxPenStyle style ) s_DC_lastcolor = Color; s_DC_lastwidth = width; s_DC_lastpenstyle = style; - s_DC_lastDC = DC; - + s_DC_lastDC = DC; } } @@ -595,28 +603,27 @@ void GRSetBrush( wxDC* DC, int Color, int fill ) if( s_ForceBlackPen ) Color = BLACK; - if( s_DC_lastbrushcolor != Color || - s_DC_lastbrushfill != fill || - s_DC_lastDC != DC ) + if( s_DC_lastbrushcolor != Color + || s_DC_lastbrushfill != fill + || s_DC_lastDC != DC ) { - wxBrush DrawBrush; - DrawBrush.SetColour( MakeColour( Color ) ); + wxBrush DrawBrush; + DrawBrush.SetColour( MakeColour( Color ) ); - if( fill ) - DrawBrush.SetStyle( wxSOLID ); - else - DrawBrush.SetStyle( wxTRANSPARENT ); + if( fill ) + DrawBrush.SetStyle( wxSOLID ); + else + DrawBrush.SetStyle( wxTRANSPARENT ); - DC->SetBrush( DrawBrush ); + DC->SetBrush( DrawBrush ); - s_DC_lastbrushcolor = Color; - s_DC_lastbrushfill = fill; - s_DC_lastDC = DC; + s_DC_lastbrushcolor = Color; + s_DC_lastbrushfill = fill; + s_DC_lastDC = DC; } } - /** function GRForceBlackPen * @param flagforce True to force a black pen whenever the asked color */ @@ -642,30 +649,40 @@ void GRSetDrawMode( wxDC* DC, int draw_mode ) { if( draw_mode & GR_OR ) #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) ) + DC->SetLogicalFunction( wxCOPY ); #elif defined( USE_WX_GRAPHICS_CONTEXT ) + DC->SetLogicalFunction( wxCOPY ); #else + DC->SetLogicalFunction( wxOR ); #endif else if( draw_mode & GR_XOR ) #if defined( USE_WX_GRAPHICS_CONTEXT ) + DC->SetLogicalFunction( wxCOPY ); #else + DC->SetLogicalFunction( wxXOR ); #endif else if( draw_mode & GR_NXOR ) #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) ) + DC->SetLogicalFunction( wxXOR ); #elif defined( USE_WX_GRAPHICS_CONTEXT ) + DC->SetLogicalFunction( wxCOPY ); #else + DC->SetLogicalFunction( wxEQUIV ); #endif else if( draw_mode & GR_INVERT ) #if defined( USE_WX_GRAPHICS_CONTEXT ) + DC->SetLogicalFunction( wxCOPY ); #else + DC->SetLogicalFunction( wxINVERT ); #endif else @@ -731,9 +748,9 @@ void GRSDashedLine( EDA_Rect* ClipBox, int width, int Color ) { - GRLastMoveToX = x2; - GRLastMoveToY = y2; - s_DC_lastcolor = -1; + GRLastMoveToX = x2; + GRLastMoveToY = y2; + s_DC_lastcolor = -1; GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH ); GRSLine( ClipBox, DC, x1, y1, x2, y2, width, Color ); s_DC_lastcolor = -1; @@ -863,7 +880,6 @@ void GRSMoveTo( int x, int y ) } - /* * Draw line to a new position, in screen (pixels) space. */ @@ -881,97 +897,67 @@ void GRSLine( EDA_Rect* ClipBox, GRLastMoveToY = y2; } -/* - * Draw an array of lines - */ -void GRLineArray(EDA_Rect* ClipBox, - wxDC* DC, - wxPoint points[], - int lines, - int width, - int Color ) +/** Function GRLineArray + * draws an array of lines (not a polygon). + * @param aClipBox = the clip box + * @param aDC = the device context into which drawing should occur. + * @param aLines = a list of pair of coordinate in user space: a pair for each line. + * @param aWidth = the width of each line. + * @param aColor = an index into our color table of RGB colors. + * @see EDA_Colors and colors.h + */ +void GRLineArray( EDA_Rect* aClipBox, wxDC* aDC, + std::vector& aLines, + int aWidth, int aColor ) { - for(int i= 0 ; i < lines; i++) + for( unsigned i = 0; i < aLines.size(); i++ ) { - points[i].x = GRMapX( points[i].x ); - points[i].y = GRMapY( points[i].y ); + aLines[i].x = GRMapX( aLines[i].x ); + aLines[i].y = GRMapY( aLines[i].y ); } - width = ZoomValue( width ); - GRSLineArray(ClipBox,DC,points,lines,width,Color); + aWidth = ZoomValue( aWidth ); + GRSLineArray( aClipBox, aDC, aLines, aWidth, aColor ); } -void GRSLineArray(EDA_Rect* ClipBox, - wxDC* DC, - wxPoint points[], - int lines, - int width, - int Color ) +void GRSLineArray( EDA_Rect* aClipBox, wxDC* aDC, + std::vector& aLines, + int aWidth, int aColor ) { - GRSetColorPen( DC, Color, width ); + GRSetColorPen( aDC, aColor, aWidth ); #if defined( USE_WX_GRAPHICS_CONTEXT ) || defined(__WXMAC__) - wxGraphicsContext *gc = wxGraphicsContext::Create( DC ); - wxASSERT(gc); - gc->Clip( ClipBox->GetX(), ClipBox->GetY(), ClipBox->GetRight(), ClipBox->GetHeight()); - wxGraphicsPath path = gc->CreatePath(); + wxGraphicsContext* gc = wxGraphicsContext::Create( aDC ); + wxASSERT( gc ); + gc->Clip( aClipBox->GetX(), aClipBox->GetY(), aClipBox->GetRight(), aClipBox->GetHeight() ); + wxGraphicsPath path = gc->CreatePath(); - for(int i= 0 ; i < lines; i+=2) + for( unsigned i = 0; i < aLines.size(); ) { - path.MoveToPoint(points[i].x, points[i].y); - path.AddLineToPoint(points[i+1].x, points[i+1].y); + path.MoveToPoint( aLines[i].x, aLines[i].y ); + i++; + path.AddLineToPoint( aLines[i].x, aLines[i].y ); + i++; } - gc->StrokePath(path); + gc->StrokePath( path ); gc->ResetClip(); delete gc; #else - for(int i= 0 ; i < lines; i+=2) + for( unsigned i = 0; i < aLines.size(); ) { - WinClipAndDrawLine( ClipBox, DC, points[i].x , points[i].y, points[i+1].x , points[i+1].y, Color, width ); - GRLastMoveToX = points[i+1].x; - GRLastMoveToY = points[i+1].y; + WinClipAndDrawLine( aClipBox, aDC, aLines[i].x, aLines[i].y, + aLines[i + 1].x, aLines[i + 1].y, aColor, aWidth ); + i++; + GRLastMoveToX = aLines[i].x; + GRLastMoveToY = aLines[i].y; + i++; } + #endif } -/* - * Move to a new position relative to current one, in object space. - */ -void GRMoveRel( int x, int y ) -{ - GRLastMoveToX += ZoomValue( x ); - GRLastMoveToY += ZoomValue( y ); -} - - -/* - * Draw a line to a new position relative to current one, in object space. - */ -void GRLineRel( EDA_Rect* ClipBox, - wxDC* DC, - int x, - int y, - int width, - int Color ) -{ - int GRLineToX = GRLastMoveToX, - GRLineToY = GRLastMoveToY; - - GRLineToX += ZoomValue( x ); - GRLineToY += ZoomValue( y ); - - GRSLine( ClipBox, - DC, - GRLastMoveToX, - GRLastMoveToY, - GRLineToX, - GRLineToY, - ZoomValue( width ), - Color ); -} - /* * Draw segment with rounded ends in object space. @@ -983,6 +969,7 @@ void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, GRMapY( y2 ), ZoomValue( width ), ZoomValue( aPenSize ), Color ); } + void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ) { @@ -990,6 +977,7 @@ void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, GRMapY( y2 ), ZoomValue( width ), 0, Color ); } + void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor ) { @@ -998,6 +986,7 @@ void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, ZoomValue( aWidth ), 0, aColor ); } + /* * Draw segment (full) with rounded ends in object space (real coords.). */ @@ -1005,7 +994,7 @@ void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ) { WinClipAndDrawLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ), - GRMapY( y2 ), Color, ZoomValue( width ) ); + GRMapY( y2 ), Color, ZoomValue( width ) ); } @@ -1013,8 +1002,8 @@ void GRFilledSegment( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEn int aWidth, int aColor ) { WinClipAndDrawLine( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ), - GRMapX( aEnd.x ), GRMapY( aEnd.y ), - aColor, ZoomValue( aWidth ) ); + GRMapX( aEnd.x ), GRMapY( aEnd.y ), + aColor, ZoomValue( aWidth ) ); } @@ -1060,6 +1049,7 @@ void GRSCSegm( EDA_Rect* ClipBox, #else if( clip_line( x1, y1, x2, y2 ) ) #endif + return; } @@ -1187,7 +1177,7 @@ void GRSCSegm( EDA_Rect* ClipBox, static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] ) { - if( ! ClipBox ) + if( !ClipBox ) return true; if( n <= 0 ) @@ -1367,6 +1357,7 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color ) GRSCircle( ClipBox, DC, cx, cy, radius, 0, Color ); } + /* * Draw a circle in object space. */ @@ -1377,13 +1368,14 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color ); } + /* * Draw a circle in object space. */ void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor ) { - aRadius = ZoomValue( aRadius ); - aWidth = ZoomValue( aWidth ); + aRadius = ZoomValue( aRadius ); + aWidth = ZoomValue( aWidth ); GRSCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, aWidth, aColor ); } @@ -1400,16 +1392,18 @@ void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, Color, BgColor ); } + /* * Draw a filled circle, in object space. */ void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor ) { - aRadius = ZoomValue( aRadius ); + aRadius = ZoomValue( aRadius ); GRSFilledCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, 0, aColor, aColor ); } + /* * Draw a filled circle, in drawing space. */ @@ -1440,7 +1434,6 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, } - /* * Draw a circle in drawing space. */ @@ -1498,6 +1491,7 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, Color ); } + void GRArc1( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, wxPoint aCenter, int aWidth, int aColor ) { @@ -1736,6 +1730,7 @@ void GRRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, int GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor ); } + void GRRectPs( EDA_Rect* aClipBox, wxDC* aDC, const EDA_Rect& aRect, int aColor, wxPenStyle aStyle ) { int x1 = GRMapX( aRect.GetX() ); @@ -1761,6 +1756,7 @@ void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int wi GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color ); } + void GRRect( EDA_Rect* aClipBox, wxDC* aDC, const EDA_Rect& aRect, int aWidth, int aColor ) { int x1 = GRMapX( aRect.GetX() ); @@ -1845,10 +1841,9 @@ void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, } - -void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, - int x1, int y1, int x2, int y2, - int width, int Color, int BgColor ) +void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, + int x1, int y1, int x2, int y2, + int width, int Color, int BgColor ) { if( x1 > x2 ) EXCHG( x1, x2 ); @@ -1916,11 +1911,11 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox, clippedPolygon.clear(); for( int ii = 0; ii < n; ii++ ) inputPolygon.push_back( PointF( (REAL) aPoints[ii].x, - (REAL) aPoints[ii].y ) ); + (REAL) aPoints[ii].y ) ); RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(), - (REAL) aClipBox->GetWidth(), - (REAL) aClipBox->GetHeight() ); + (REAL) aClipBox->GetWidth(), + (REAL) aClipBox->GetHeight() ); SutherlandHodgman sh( window ); sh.Clip( inputPolygon, outputPolygon ); @@ -1930,7 +1925,7 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox, ++cit ) { clippedPolygon.push_back( wxPoint( wxRound( cit->X ), - wxRound( cit->Y ) ) ); + wxRound( cit->Y ) ) ); } if( clippedPolygon.size() ) diff --git a/gerbview/edit.cpp b/gerbview/edit.cpp index 97ea787322..af512e6402 100644 --- a/gerbview/edit.cpp +++ b/gerbview/edit.cpp @@ -116,26 +116,10 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) Close( TRUE ); break; - case ID_NEW_PROJECT: - case ID_LOAD_PROJECT: - Files_io( event ); - break; - case ID_GERBVIEW_GLOBAL_DELETE: Erase_Current_Layer( TRUE ); break; - case ID_GET_TOOLS: - -// InstallToolsFrame(this, wxPoint(-1,-1) ); - break; - - case ID_FIND_ITEMS: - -// InstallFindFrame(this, pos); - break; - - case ID_NO_SELECT_BUTT: SetToolID( 0, 0, wxEmptyString ); break; @@ -223,19 +207,5 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) */ void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) { - EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); - - switch( m_ID_current_state ) - { - case 0: - if( (DrawStruct == NULL) || ((DrawStruct->m_Flags & ~DRAW_ERASED) == 0) ) - { - DrawStruct = GerberGeneralLocateAndDisplay(); - } - - break; - - default: - break; - } + // Currently: no nothing } diff --git a/gerbview/gerberframe.cpp b/gerbview/gerberframe.cpp index c3ec671fc0..9afd1a03dc 100644 --- a/gerbview/gerberframe.cpp +++ b/gerbview/gerberframe.cpp @@ -169,7 +169,7 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father, ReCreateMenuBar(); ReCreateHToolbar(); - ReCreateVToolbar(); +// ReCreateVToolbar(); // Currently: no right vertical toolbar ReCreateOptToolbar(); m_auimgr.SetManagedWindow( this ); diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 81257af807..5c7798b3b1 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -47,13 +47,6 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) wxBitmap( open_xpm ), _( "Load a new Gerber file on the current layer. Previous data will be deleted" ) ); - - m_HToolBar->AddSeparator(); - - m_HToolBar->AddTool( wxID_UNDO, wxEmptyString, - wxBitmap( undelete_xpm ), - _( "Undelete" ) ); - m_HToolBar->AddSeparator(); m_HToolBar->AddTool( wxID_PRINT, wxEmptyString, wxBitmap( print_button ), diff --git a/include/gr_basic.h b/include/gr_basic.h index 48d8ed1568..f89e047031 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -77,8 +77,6 @@ void GRDashedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, int Color ); void GRMoveTo( int x, int y ); void GRLineTo( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color ); -void GRMoveRel( int x, int y ); -void GRLineRel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color ); void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill, int width, int Color, int BgColor ); @@ -204,7 +202,16 @@ void GRRectPs( EDA_Rect* aClipBox, wxDC* aDC,const EDA_Rect& aRect, void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color, int BgColor ); -void GRLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[], - int lines, int width, int Color ); +/** Function GRLineArray + * draws an array of lines (not a polygon). + * @param aClipBox = the clip box + * @param aDC = the device context into which drawing should occur. + * @param aLines = a list of pair of coordinate in user space: a pair for each line. + * @param aWidth = the width of each line. + * @param aColor = an index into our color table of RGB colors. + * @see EDA_Colors and colors.h + */ +void GRLineArray( EDA_Rect* aClipBox, wxDC* aDC,std::vector& aLines, + int aWidth, int aColor ); #endif /* define GR_BASIC */ diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 4d07bebb58..0f30fa4468 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -18,7 +18,6 @@ #include "protos.h" - /************************/ /* class ZONE_CONTAINER */ /************************/ @@ -477,7 +476,8 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con // draw the lines int i_start_contour = 0; - wxPoint lines[( GetNumCorners()*2)+2]; + std::vector lines; + lines.reserve( (GetNumCorners()*2)+2); for( int ic = 0; ic < GetNumCorners(); ic++ ) { seg_start = GetCornerPosition( ic ) + offset; @@ -490,23 +490,24 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con seg_end = GetCornerPosition( i_start_contour ) + offset; i_start_contour = ic + 1; } - lines[ic*2].x = seg_start.x; - lines[ic*2].y = seg_start.y; - lines[ic*2+1].x = seg_start.x; - lines[ic*2+1].y = seg_start.y; + lines.push_back( seg_start ); + lines.push_back( seg_end ); } - GRLineArray(&panel->m_ClipBox, DC, lines, GetNumCorners(), 0, color); + GRLineArray(&panel->m_ClipBox, DC, lines, 0, color); // draw hatches - wxPoint hatches[(m_Poly->m_HatchLines.size() *2)+2]; + lines.clear(); + lines.reserve( (m_Poly->m_HatchLines.size() *2) +2 ); for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ ) { - hatches[ic*2].x = m_Poly->m_HatchLines[ic].xi + offset.x; - hatches[ic*2].y = m_Poly->m_HatchLines[ic].yi + offset.y; - hatches[ic*2+1].x = m_Poly->m_HatchLines[ic].xf + offset.x; - hatches[ic*2+1].y = m_Poly->m_HatchLines[ic].yf + offset.y; + seg_start.x = m_Poly->m_HatchLines[ic].xi + offset.x; + seg_start.y = m_Poly->m_HatchLines[ic].yi + offset.y; + seg_end.x = m_Poly->m_HatchLines[ic].xf + offset.x; + seg_end.y = m_Poly->m_HatchLines[ic].yf + offset.y; + lines.push_back( seg_start ); + lines.push_back( seg_end ); } - GRLineArray(&panel->m_ClipBox, DC, hatches, m_Poly->m_HatchLines.size(), 0, color ); + GRLineArray(&panel->m_ClipBox, DC, lines, 0, color ); }