Commit ea812ef5 authored by Marco Serantoni's avatar Marco Serantoni
Browse files

Zones drawing optimization with WXGrapchisContext + Fix bug #612132

parent fc0864be
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ option(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is
option(USE_WX_GRAPHICS_CONTEXT
       "Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")

option(USE_WX_OVERLAY
       "Use wxOverlay: Always ON for MAC (default OFF). Warning, this is experimental")

option(USE_BOOST_POLYGON_LIBRARY
       "Use boost polygon library instead of Kbool to calculate filled areas in zones (default OFF). Warning, this is experimental")

@@ -54,6 +57,11 @@ if(USE_WX_ZOOM)
    add_definitions(-DUSE_WX_ZOOM)
endif(USE_WX_ZOOM)

if(USE_WX_OVERLAY OR APPLE)
    add_definitions(-DUSE_WX_OVERLAY)
endif(USE_WX_OVERLAY OR APPLE)


if(USE_WX_GRAPHICS_CONTEXT)
    set( USE_WX_ZOOM ON )
    add_definitions(-DUSE_WX_ZOOM)
+55 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "class_base_screen.h"
#include "bezier_curves.h"
#include "math_for_graphics.h"
#include <wx/graphics.h>


#ifndef FILLED
@@ -880,6 +881,60 @@ 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 )
{
    for(int i= 0 ; i < lines; i++) 
    {
      points[i].x = GRMapX( points[i].x );
      points[i].y = GRMapY( points[i].y );
    }

    width = ZoomValue( width );
    GRSLineArray(ClipBox,DC,points,lines,width,Color);
}


void GRSLineArray(EDA_Rect*  ClipBox,
                  wxDC*      DC,
                  wxPoint    points[],
                  int        lines,
                  int        width,
                  int        Color )
{
    GRSetColorPen( DC, Color, width );
#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();
    
    for(int i= 0 ; i < lines; i+=2)
    {
      path.MoveToPoint(points[i].x, points[i].y);
      path.AddLineToPoint(points[i+1].x, points[i+1].y);
    }

    gc->StrokePath(path);
    gc->ResetClip();
    delete gc;
#else
    for(int i= 0 ; i < lines; i+=2) 
    {
      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;
    }
#endif
}

/*
 * Move to a new position relative to current one, in object space.
+91 −91
Original line number Diff line number Diff line
update=01/05/2010 14:42:54
update=Sabato, 2010 Ottobre 09 10:06:24
version=1
last_client=pcbnew
[cvpcb]
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public:
    int  m_CursorLevel;                     // Index for cursor redraw in XOR
                                            // mode

#ifdef __WXMAC__
#ifdef USE_WX_OVERLAY
    // MAC Uses overlay to workaround the wxINVERT and wxXOR miss
    wxOverlay               m_overlay; 
#endif
+5 −0
Original line number Diff line number Diff line
@@ -198,4 +198,9 @@ 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 );
void GRSLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[],
                   int lines, int width, int Color );

#endif      /* define GR_BASIC */
Loading