Commit ea812ef5 authored by Marco Serantoni's avatar Marco Serantoni

Zones drawing optimization with WXGrapchisContext + Fix bug #612132

parent fc0864be
...@@ -24,6 +24,9 @@ option(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is ...@@ -24,6 +24,9 @@ option(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is
option(USE_WX_GRAPHICS_CONTEXT option(USE_WX_GRAPHICS_CONTEXT
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental") "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 option(USE_BOOST_POLYGON_LIBRARY
"Use boost polygon library instead of Kbool to calculate filled areas in zones (default OFF). Warning, this is experimental") "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) ...@@ -54,6 +57,11 @@ if(USE_WX_ZOOM)
add_definitions(-DUSE_WX_ZOOM) add_definitions(-DUSE_WX_ZOOM)
endif(USE_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) if(USE_WX_GRAPHICS_CONTEXT)
set( USE_WX_ZOOM ON ) set( USE_WX_ZOOM ON )
add_definitions(-DUSE_WX_ZOOM) add_definitions(-DUSE_WX_ZOOM)
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "class_base_screen.h" #include "class_base_screen.h"
#include "bezier_curves.h" #include "bezier_curves.h"
#include "math_for_graphics.h" #include "math_for_graphics.h"
#include <wx/graphics.h>
#ifndef FILLED #ifndef FILLED
...@@ -880,6 +881,60 @@ void GRSLine( EDA_Rect* ClipBox, ...@@ -880,6 +881,60 @@ void GRSLine( EDA_Rect* ClipBox,
GRLastMoveToY = y2; 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. * Move to a new position relative to current one, in object space.
......
update=01/05/2010 14:42:54 update=Sabato, 2010 Ottobre 09 10:06:24
version=1 version=1
last_client=pcbnew last_client=pcbnew
[cvpcb] [cvpcb]
version=1 version=1
NetITyp=0 NetITyp=0
NetIExt=.net NetIExt=.net
PkgIExt=.pkg PkgIExt=.pkg
NetDir= NetDir=
LibDir= LibDir=
NetType=0 NetType=0
[cvpcb/libraries] [cvpcb/libraries]
EquName1=devcms EquName1=devcms
[general] [general]
version=1 version=1
RootSch=video.sch RootSch=video.sch
BoardNm=video.brd BoardNm=video.brd
[eeschema] [eeschema]
version=1 version=1
LibDir= LibDir=
NetFmt=1 NetFmt=1
HPGLSpd=20 HPGLSpd=20
HPGLDm=15 HPGLDm=15
HPGLNum=1 HPGLNum=1
offX_A4=0 offX_A4=0
offY_A4=0 offY_A4=0
offX_A3=0 offX_A3=0
offY_A3=0 offY_A3=0
offX_A2=0 offX_A2=0
offY_A2=0 offY_A2=0
offX_A1=0 offX_A1=0
offY_A1=0 offY_A1=0
offX_A0=0 offX_A0=0
offY_A0=0 offY_A0=0
offX_A=0 offX_A=0
offY_A=0 offY_A=0
offX_B=0 offX_B=0
offY_B=0 offY_B=0
offX_C=0 offX_C=0
offY_C=0 offY_C=0
offX_D=0 offX_D=0
offY_D=0 offY_D=0
offX_E=0 offX_E=0
offY_E=0 offY_E=0
RptD_X=0 RptD_X=0
RptD_Y=100 RptD_Y=100
RptLab=1 RptLab=1
PenMin=20 PenMin=20
SimCmd= SimCmd=
UseNetN=0 UseNetN=0
[eeschema/libraries] [eeschema/libraries]
LibName1=power LibName1=power
LibName2=device LibName2=device
LibName3=conn LibName3=conn
LibName4=brooktre LibName4=brooktre
LibName5=linear LibName5=linear
LibName6=regul LibName6=regul
LibName7=74xx LibName7=74xx
LibName8=cmos4000 LibName8=cmos4000
LibName9=adc-dac LibName9=adc-dac
LibName10=memory LibName10=memory
LibName11=xilinx LibName11=xilinx
LibName12=special LibName12=special
LibName13=analog_switches LibName13=analog_switches
LibName14=philips LibName14=philips
[pcbnew] [pcbnew]
version=1 version=1
PadDrlX=1200 PadDrlX=1200
PadDimH=1500 PadDimH=1500
PadDimV=2000 PadDimV=2000
BoardThickness=630 BoardThickness=630
SgPcb45=1 SgPcb45=1
TxtPcbV=600 TxtPcbV=600
TxtPcbH=600 TxtPcbH=600
TxtModV=500 TxtModV=500
TxtModH=500 TxtModH=500
TxtModW=80 TxtModW=80
VEgarde=100 VEgarde=100
DrawLar=120 DrawLar=120
EdgeLar=120 EdgeLar=120
TxtLar=80 TxtLar=80
MSegLar=120 MSegLar=120
LastNetListRead= LastNetListRead=
[pcbnew/libraries] [pcbnew/libraries]
LibDir= LibDir=
LibName1=supports LibName1=supports
LibName2=connect LibName2=connect
LibName3=discret LibName3=discret
LibName4=pin_array LibName4=pin_array
LibName5=divers LibName5=divers
LibName6=libcms LibName6=libcms
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
int m_CursorLevel; // Index for cursor redraw in XOR int m_CursorLevel; // Index for cursor redraw in XOR
// mode // mode
#ifdef __WXMAC__ #ifdef USE_WX_OVERLAY
// MAC Uses overlay to workaround the wxINVERT and wxXOR miss // MAC Uses overlay to workaround the wxINVERT and wxXOR miss
wxOverlay m_overlay; wxOverlay m_overlay;
#endif #endif
......
...@@ -198,4 +198,9 @@ void GRRectPs( EDA_Rect* aClipBox, wxDC* aDC,const EDA_Rect& aRect, ...@@ -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, void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color, int BgColor ); 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 */ #endif /* define GR_BASIC */
...@@ -186,7 +186,7 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -186,7 +186,7 @@ void MODULE::Copy( MODULE* aModule )
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& offset ) int draw_mode, const wxPoint& offset )
{ {
if( (m_Flags & DO_NOT_DRAW) ) if( (m_Flags & DO_NOT_DRAW) || (m_Flags & IS_MOVED) )
return; return;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
......
...@@ -477,6 +477,7 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con ...@@ -477,6 +477,7 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con
// draw the lines // draw the lines
int i_start_contour = 0; int i_start_contour = 0;
wxPoint lines[( GetNumCorners()*2)+2];
for( int ic = 0; ic < GetNumCorners(); ic++ ) for( int ic = 0; ic < GetNumCorners(); ic++ )
{ {
seg_start = GetCornerPosition( ic ) + offset; seg_start = GetCornerPosition( ic ) + offset;
...@@ -489,18 +490,23 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con ...@@ -489,18 +490,23 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, con
seg_end = GetCornerPosition( i_start_contour ) + offset; seg_end = GetCornerPosition( i_start_contour ) + offset;
i_start_contour = ic + 1; i_start_contour = ic + 1;
} }
GRLine( &panel->m_ClipBox, DC, seg_start.x, seg_start.y, seg_end.x, seg_end.y, 0, color ); 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;
} }
GRLineArray(&panel->m_ClipBox, DC, lines, GetNumCorners(), 0, color);
// draw hatches // draw hatches
wxPoint hatches[(m_Poly->m_HatchLines.size() *2)+2];
for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ ) for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ )
{ {
int xi = m_Poly->m_HatchLines[ic].xi + offset.x; hatches[ic*2].x = m_Poly->m_HatchLines[ic].xi + offset.x;
int yi = m_Poly->m_HatchLines[ic].yi + offset.y; hatches[ic*2].y = m_Poly->m_HatchLines[ic].yi + offset.y;
int xf = m_Poly->m_HatchLines[ic].xf + offset.x; hatches[ic*2+1].x = m_Poly->m_HatchLines[ic].xf + offset.x;
int yf = m_Poly->m_HatchLines[ic].yf + offset.y; hatches[ic*2+1].y = m_Poly->m_HatchLines[ic].yf + offset.y;
GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color );
} }
GRLineArray(&panel->m_ClipBox, DC, hatches, m_Poly->m_HatchLines.size(), 0, color );
} }
......
...@@ -361,7 +361,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -361,7 +361,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
#ifdef __WXMAC__ #ifdef USE_WX_OVERLAY
wxDCOverlay oDC( DrawPanel->m_overlay, DC ); wxDCOverlay oDC( DrawPanel->m_overlay, DC );
oDC.Clear(); oDC.Clear();
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -369,7 +369,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -369,7 +369,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
#endif #endif
} }
#ifdef __WXMAC__ #ifdef USE_WX_OVERLAY
else else
DrawPanel->m_overlay.Reset(); DrawPanel->m_overlay.Reset();
#endif #endif
......
...@@ -91,7 +91,7 @@ void WinEDA_ModuleEditFrame::ReCreateMenuBar() ...@@ -91,7 +91,7 @@ void WinEDA_ModuleEditFrame::ReCreateMenuBar()
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
/* Print */ /* Print */
item = new wxMenuItem( fileMenu, wxID_PRINT, _( "&Print" ), item = new wxMenuItem( fileMenu, wxID_PRINT, _( "&Print\tCtrl+P" ),
_( "Print the current module" ) ); _( "Print the current module" ) );
item->SetBitmap( plot_xpm ); item->SetBitmap( plot_xpm );
fileMenu->Append( item ); fileMenu->Append( item );
......
...@@ -195,7 +195,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar() ...@@ -195,7 +195,7 @@ void WinEDA_PcbFrame::ReCreateMenuBar()
filesMenu->AppendSeparator(); filesMenu->AppendSeparator();
/* Print */ /* Print */
item = new wxMenuItem( filesMenu, wxID_PRINT, _( "&Print" ), item = new wxMenuItem( filesMenu, wxID_PRINT, _( "&Print\tCtrl+P" ),
_( "Print board" ) ); _( "Print board" ) );
item->SetBitmap( print_button ); item->SetBitmap( print_button );
filesMenu->Append( item ); filesMenu->Append( item );
......
...@@ -224,6 +224,10 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -224,6 +224,10 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
pcbframe->GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST; pcbframe->GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
if( pcbframe->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( pcbframe->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
pcbframe->DrawGeneralRatsnest( DC ); pcbframe->DrawGeneralRatsnest( DC );
#ifdef __WXMAC__
pcbframe->GetScreen()->SetRefreshReq();
#endif
} }
......
...@@ -54,7 +54,7 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -54,7 +54,7 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
module->Draw( DrawPanel, DC, GR_OR ); module->Draw( DrawPanel, DC, GR_OR );
} }
#ifdef __WXMAC__ #ifdef USE_WX_OVERLAY
DrawPanel->m_overlay.Reset(); DrawPanel->m_overlay.Reset();
wxDCOverlay overlaydc( DrawPanel->m_overlay, DC ); wxDCOverlay overlaydc( DrawPanel->m_overlay, DC );
overlaydc.Clear(); overlaydc.Clear();
...@@ -90,7 +90,7 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -90,7 +90,7 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
#ifdef __WXMAC__ #ifdef USE_WX_OVERLAY
DrawPanel->m_overlay.Reset(); DrawPanel->m_overlay.Reset();
wxDCOverlay overlaydc( DrawPanel->m_overlay, DC ); wxDCOverlay overlaydc( DrawPanel->m_overlay, DC );
overlaydc.Clear(); overlaydc.Clear();
......
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