Commit d657b430 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Use wxDC for all coordinate manipulations.

* Remove all occurrences if #ifdef USE_WX_ZOOM and all associated code within
  the #else/#endif block ( old zoom code ).
* Removed the build option for USE_WX_ZOOM from CMakeList.txt and config.h.in.
* Removed all scaling code in base screen object.
* Fixed buffered paint and buffered client DC on Windows.  Buffering works
  properly on Linux and Windows.
* Modified kicad_device_context.h to automatically uses buffering on platforms
  where double buffering is supported natively.
* Remove all of the scaled versions of the drawing functions in gr_basic.cpp
  and any support code.
* Removed all traces of ActiveScreen global variable from eeschema and
  gerbview.
* Renamed Recadre_Trace to RedrawScreen in draw frame object.
* Renamed PostDirtyRect to RefreshDrawingRect in draw panel object.
* Lots of code cleaning an Doxygen comment improvements.
parent 654b8909
...@@ -22,8 +22,6 @@ option(KICAD_GOST "enable/disable building using GOST notation for multiple gate ...@@ -22,8 +22,6 @@ option(KICAD_GOST "enable/disable building using GOST notation for multiple gate
#for those who bored with uppercase #for those who bored with uppercase
option(KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected") option(KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected")
option(USE_WX_ZOOM "Use wxDC to perform zooming (default ON)." ON)
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")
...@@ -61,18 +59,12 @@ if(KICAD_KEEPCASE) ...@@ -61,18 +59,12 @@ if(KICAD_KEEPCASE)
add_definitions(-DKICAD_KEEPCASE) add_definitions(-DKICAD_KEEPCASE)
endif(KICAD_KEEPCASE) endif(KICAD_KEEPCASE)
if(USE_WX_ZOOM)
add_definitions(-DUSE_WX_ZOOM)
endif(USE_WX_ZOOM)
if(USE_WX_OVERLAY OR APPLE) if(USE_WX_OVERLAY OR APPLE)
add_definitions(-DUSE_WX_OVERLAY) add_definitions(-DUSE_WX_OVERLAY)
endif(USE_WX_OVERLAY OR APPLE) endif(USE_WX_OVERLAY OR APPLE)
if(USE_WX_GRAPHICS_CONTEXT) if(USE_WX_GRAPHICS_CONTEXT)
set( USE_WX_ZOOM ON )
add_definitions(-DUSE_WX_ZOOM)
add_definitions(-DUSE_WX_GRAPHICS_CONTEXT) add_definitions(-DUSE_WX_GRAPHICS_CONTEXT)
endif(USE_WX_GRAPHICS_CONTEXT) endif(USE_WX_GRAPHICS_CONTEXT)
......
...@@ -49,9 +49,6 @@ ...@@ -49,9 +49,6 @@
#define strnicmp _strnicmp #define strnicmp _strnicmp
#endif #endif
/* Warning!!! Using wxDC for zooming is experimental. */
#cmakedefine USE_WX_ZOOM 1
/* Warning!!! Using wxGraphicContext for rendering is experimental. */ /* Warning!!! Using wxGraphicContext for rendering is experimental. */
#cmakedefine USE_WX_GRAPHICS_CONTEXT 1 #cmakedefine USE_WX_GRAPHICS_CONTEXT 1
......
...@@ -101,23 +101,6 @@ void BASE_SCREEN::SetPageSize( wxSize& aPageSize ) ...@@ -101,23 +101,6 @@ void BASE_SCREEN::SetPageSize( wxSize& aPageSize )
} }
/**
* Function CursorRealPosition
* @return the position in user units of location ScreenPos
* @param ScreenPos = the screen (in pixel) position co convert
*/
wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
{
wxPoint curpos = ScreenPos;
Unscale( curpos );
#ifndef USE_WX_ZOOM
curpos += m_DrawOrg;
#endif
return curpos;
}
/** /**
* Function SetScalingFactor * Function SetScalingFactor
* calculates the .m_Zoom member to have a given scaling factor * calculates the .m_Zoom member to have a given scaling factor
...@@ -131,113 +114,15 @@ void BASE_SCREEN::SetScalingFactor(double aScale ) ...@@ -131,113 +114,15 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
// Limit zoom to max and min allowed values: // Limit zoom to max and min allowed values:
if (zoom < m_ZoomList[0]) if (zoom < m_ZoomList[0])
zoom = m_ZoomList[0]; zoom = m_ZoomList[0];
int idxmax = m_ZoomList.GetCount() - 1; int idxmax = m_ZoomList.GetCount() - 1;
if (zoom > m_ZoomList[idxmax]) if (zoom > m_ZoomList[idxmax])
zoom = m_ZoomList[idxmax]; zoom = m_ZoomList[idxmax];
SetZoom( zoom ); SetZoom( zoom );
} }
/**
* Calculate coordinate value for zooming.
*
* Call this method when drawing on the device context. It scales the
* coordinate using the current zoom settings. Zooming in Kicad occurs
* by actually scaling the entire drawing using the zoom setting.
*
* FIXME: We should probably use wxCoord instead of int here but that would
* require using wxCoord in all of the other code that makes device
* context calls as well.
*/
int BASE_SCREEN::Scale( int coord )
{
#ifdef USE_WX_ZOOM
return coord;
#else
if( !m_ZoomScalar || !m_Zoom )
return coord;
return wxRound( (double) ( coord * m_ZoomScalar ) / (double) m_Zoom );
#endif
}
double BASE_SCREEN::Scale( double coord )
{
#ifdef USE_WX_ZOOM
return coord;
#else
if( !m_Zoom )
return 0;
if( !m_ZoomScalar || !m_Zoom )
return 0;
return ( coord * (double) m_ZoomScalar ) / (double) m_Zoom;
#endif
}
void BASE_SCREEN::Scale( wxPoint& pt )
{
pt.x = Scale( pt.x );
pt.y = Scale( pt.y );
}
void BASE_SCREEN::Scale( wxRealPoint& pt )
{
#ifdef USE_WX_ZOOM
// No change
#else
if( !m_ZoomScalar || !m_Zoom )
return;
pt.x = pt.x * m_ZoomScalar / (double) m_Zoom;
pt.y = pt.y * m_ZoomScalar / (double) m_Zoom;
#endif
}
void BASE_SCREEN::Scale( wxSize& sz )
{
sz.SetHeight( Scale( sz.GetHeight() ) );
sz.SetWidth( Scale( sz.GetWidth() ) );
}
/**
* Calculate the physical (unzoomed) location of a coordinate.
*
* Call this method when you want to find the unzoomed (physical) location
* of a coordinate on the drawing.
*/
int BASE_SCREEN::Unscale( int coord )
{
#ifdef USE_WX_ZOOM
return coord;
#else
if( !m_Zoom || !m_ZoomScalar )
return 0;
return wxRound( (double) ( coord * m_Zoom ) / (double) m_ZoomScalar );
#endif
}
void BASE_SCREEN::Unscale( wxPoint& pt )
{
pt.x = Unscale( pt.x );
pt.y = Unscale( pt.y );
}
void BASE_SCREEN::Unscale( wxSize& sz )
{
sz.SetHeight( Unscale( sz.GetHeight() ) );
sz.SetWidth( Unscale( sz.GetWidth() ) );
}
void BASE_SCREEN::SetZoomList( const wxArrayInt& zoomlist ) void BASE_SCREEN::SetZoomList( const wxArrayInt& zoomlist )
{ {
if( !m_ZoomList.IsEmpty() ) if( !m_ZoomList.IsEmpty() )
......
...@@ -399,11 +399,7 @@ void EDA_TextStruct::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -399,11 +399,7 @@ void EDA_TextStruct::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aAnchor_color != UNSPECIFIED_COLOR ) if( aAnchor_color != UNSPECIFIED_COLOR )
{ {
#if USE_WX_ZOOM
int anchor_size = aDC->DeviceToLogicalXRel( 2 ); int anchor_size = aDC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = aPanel->GetScreen()->Unscale( 2 );
#endif
aAnchor_color = (EDA_Colors) ( aAnchor_color & MASKCOLOR ); aAnchor_color = (EDA_Colors) ( aAnchor_color & MASKCOLOR );
......
...@@ -96,16 +96,15 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) ...@@ -96,16 +96,15 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
} }
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
const wxPoint& aOffset, int aDrawMode, int aColor )
int aDrawMode,
int aColor )
{ {
int w = aPanel->GetScreen()->Scale( GetWidth() ); int w = GetWidth();
int h = aPanel->GetScreen()->Scale( GetHeight() ); int h = GetHeight();
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
if( w == 0 || h == 0 ) if( w == 0 || h == 0 )
GRLine( &aPanel->m_ClipBox, aDC, GetX() + aOffset.x, GetY() + aOffset.y, GRLine( &aPanel->m_ClipBox, aDC, GetX() + aOffset.x, GetY() + aOffset.y,
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor ); GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
......
...@@ -289,7 +289,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) ...@@ -289,7 +289,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
return; return;
GetBaseScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); GetBaseScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
GetBaseScreen()->SetZoom( selectedZoom ); GetBaseScreen()->SetZoom( selectedZoom );
Recadre_Trace( false ); RedrawScreen( false );
} }
} }
......
This diff is collapsed.
...@@ -287,10 +287,10 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -287,10 +287,10 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aPanel ) if( aPanel )
{ {
int xm, ym, ll, xc, yc; int xm, ym, ll, xc, yc;
ll = aPanel->GetScreen()->Scale( ABS( dx ) ); ll = ABS( dx );
xc = GRMapX( current_char_pos.x ); xc = current_char_pos.x;
yc = GRMapY( current_char_pos.y ); yc = current_char_pos.y;
x0 = aPanel->m_ClipBox.GetX() - ll; x0 = aPanel->m_ClipBox.GetX() - ll;
y0 = aPanel->m_ClipBox.GetY() - ll; y0 = aPanel->m_ClipBox.GetY() - ll;
...@@ -343,11 +343,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -343,11 +343,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
} }
// Note: if aPanel == NULL, we are using a GL Canvas that handle scaling // Note: if aPanel == NULL, we are using a GL Canvas that handle scaling
if( aPanel && aPanel->GetScreen()->Scale( aSize.x ) == 0 ) if( aSize.x == 0 )
return; return;
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single graphic line */ /* if a text size is too small, the text cannot be drawn, and it is drawn as a single
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 ) * graphic line */
if( aSize.x < 3 )
{ {
/* draw the text as a line always vertically centered */ /* draw the text as a line always vertically centered */
wxPoint end( current_char_pos.x + dx, current_char_pos.y ); wxPoint end( current_char_pos.x + dx, current_char_pos.y );
......
This diff is collapsed.
...@@ -17,33 +17,30 @@ ...@@ -17,33 +17,30 @@
#include "kicad_device_context.h" #include "kicad_device_context.h"
#include "hotkeys_basic.h" #include "hotkeys_basic.h"
/** Compute draw offset (scroll bars and draw parameters)
* in order to have the current graphic cursor position at the screen center void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer )
* @param ToMouse if TRUE, the mouse cursor is moved
* to the graphic cursor position (which is usually on grid)
*
* Note: Mac OS ** does not ** allow moving mouse cursor by program.
*/
void EDA_DRAW_FRAME::Recadre_Trace( bool ToMouse )
{ {
PutOnGrid( &(GetBaseScreen()->m_Curseur) ); PutOnGrid( &(GetBaseScreen()->m_Curseur) );
AdjustScrollBars(); AdjustScrollBars();
#if !(defined(__WXMAC__) && defined(USE_WX_ZOOM)) #if !defined(__WXMAC__)
/* We do not use here DrawPanel->Refresh() because /* DrawPanel->Refresh() is not used here because the redraw is delayed and the mouse
* the redraw is delayed and the mouse events (from MouseToCursorSchema ot others) * events (from MouseToCursorSchema ot others) during this delay create problems: the
* during this delay create problems: the mouse cursor position is false in calculations. * mouse cursor position is false in calculations. TODO: see exactly how the mouse
* TODO: see exactly how the mouse creates problems when moving during refresh * creates problems when moving during refresh use Refresh() and update() do not change
* use Refresh() and update() do not change problems * problems
*/ */
INSTALL_DC( dc, DrawPanel ); INSTALL_DC( dc, DrawPanel );
DrawPanel->SetClipBox( dc );
DrawPanel->ReDraw( &dc, DrawPanel->m_DisableEraseBG ? false : true ); DrawPanel->ReDraw( &dc, DrawPanel->m_DisableEraseBG ? false : true );
#else #else
DrawPanel->Refresh(); DrawPanel->Refresh();
DrawPanel->Update(); DrawPanel->Update();
#endif #endif
/* Move the mouse cursor to the on grid graphic cursor position */ /* Move the mouse cursor to the on grid graphic cursor position */
if( ToMouse == TRUE ) if( aWarpPointer )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
...@@ -77,7 +74,7 @@ void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize ) ...@@ -77,7 +74,7 @@ void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize )
void EDA_DRAW_FRAME::Zoom_Automatique( bool move_mouse_cursor ) void EDA_DRAW_FRAME::Zoom_Automatique( bool move_mouse_cursor )
{ {
GetBaseScreen()->SetZoom( BestZoom() ); // Set the best zoom GetBaseScreen()->SetZoom( BestZoom() ); // Set the best zoom
Recadre_Trace( move_mouse_cursor ); // Set the best centering and refresh the screen RedrawScreen( move_mouse_cursor ); // Set the best centering and refresh the screen
} }
...@@ -101,7 +98,7 @@ void EDA_DRAW_FRAME::Window_Zoom( EDA_Rect& Rect ) ...@@ -101,7 +98,7 @@ void EDA_DRAW_FRAME::Window_Zoom( EDA_Rect& Rect )
GetBaseScreen()->SetScalingFactor( bestscale ); GetBaseScreen()->SetScalingFactor( bestscale );
GetBaseScreen()->m_Curseur = Rect.Centre(); GetBaseScreen()->m_Curseur = Rect.Centre();
Recadre_Trace( TRUE ); RedrawScreen( TRUE );
} }
...@@ -130,7 +127,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) ...@@ -130,7 +127,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( id == ID_ZOOM_IN ) if( id == ID_ZOOM_IN )
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
if( screen->SetPreviousZoom() ) if( screen->SetPreviousZoom() )
Recadre_Trace( zoom_at_cursor ); RedrawScreen( zoom_at_cursor );
break; break;
case ID_POPUP_ZOOM_OUT: case ID_POPUP_ZOOM_OUT:
...@@ -142,7 +139,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) ...@@ -142,7 +139,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( id == ID_ZOOM_OUT ) if( id == ID_ZOOM_OUT )
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
if( screen->SetNextZoom() ) if( screen->SetNextZoom() )
Recadre_Trace( zoom_at_cursor ); RedrawScreen( zoom_at_cursor );
break; break;
case ID_ZOOM_REDRAW: case ID_ZOOM_REDRAW:
...@@ -150,7 +147,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) ...@@ -150,7 +147,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break; break;
case ID_POPUP_ZOOM_CENTER: case ID_POPUP_ZOOM_CENTER:
Recadre_Trace( true ); RedrawScreen( true );
break; break;
case ID_ZOOM_PAGE: case ID_ZOOM_PAGE:
...@@ -174,7 +171,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) ...@@ -174,7 +171,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
return; return;
} }
if( screen->SetZoom( screen->m_ZoomList[i] ) ) if( screen->SetZoom( screen->m_ZoomList[i] ) )
Recadre_Trace( true ); RedrawScreen( true );
} }
UpdateStatusBar(); UpdateStatusBar();
......
...@@ -492,7 +492,7 @@ void WinEDA_CvpcbFrame::DisplayModule( wxCommandEvent& event ) ...@@ -492,7 +492,7 @@ void WinEDA_CvpcbFrame::DisplayModule( wxCommandEvent& event )
{ {
CreateScreenCmp(); CreateScreenCmp();
DrawFrame->AdjustScrollBars(); DrawFrame->AdjustScrollBars();
DrawFrame->Recadre_Trace( FALSE ); DrawFrame->RedrawScreen( FALSE );
} }
......
...@@ -236,6 +236,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -236,6 +236,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
GetScreen()->BreakSegmentsOnJunctions(); GetScreen()->BreakSegmentsOnJunctions();
// fall through // fall through
case BLOCK_ROTATE: case BLOCK_ROTATE:
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
...@@ -243,6 +244,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -243,6 +244,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->UpdatePickList(); GetScreen()->UpdatePickList();
// fall through // fall through
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->GetCount() ) if( block->GetCount() )
{ {
...@@ -297,7 +299,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -297,7 +299,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_FLIP: /* pcbnew only! */ case BLOCK_FLIP: /* pcbnew only! */
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true; zoom_command = true;
break; break;
...@@ -308,9 +309,10 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -308,9 +309,10 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
} }
} }
if( block->m_Command == BLOCK_ABORT ) if( block->m_Command == BLOCK_ABORT )
{ {
GetScreen()->ClearDrawingState(); GetScreen()->ClearDrawingState();
DrawPanel->Refresh();
} }
if( ! nextcmd ) if( ! nextcmd )
...@@ -327,7 +329,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -327,7 +329,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if( zoom_command ) if( zoom_command )
Window_Zoom( GetScreen()->m_BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
return nextcmd ; return nextcmd;
} }
......
...@@ -365,7 +365,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) ...@@ -365,7 +365,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
{ {
case SCH_JUNCTION_T: case SCH_JUNCTION_T:
case SCH_LINE_T: case SCH_LINE_T:
DrawPanel->PostDirtyRect( item->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( item->GetBoundingBox() );
break; break;
default: default:
......
...@@ -366,11 +366,8 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff ...@@ -366,11 +366,8 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff
/* Enable this to draw the anchor of the component. */ /* Enable this to draw the anchor of the component. */
#if 0 #if 0
#ifdef USE_WX_ZOOM
int len = aDc->DeviceToLogicalXRel( 3 ); int len = aDc->DeviceToLogicalXRel( 3 );
#else
int len = aPanel->GetScreen()->Unscale( 3 );
#endif
GRLine( &aPanel->m_ClipBox, aDc, aOffset.x, aOffset.y - len, aOffset.x, GRLine( &aPanel->m_ClipBox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
aOffset.y + len, 0, aColor ); aOffset.y + len, 0, aColor );
GRLine( &aPanel->m_ClipBox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len, GRLine( &aPanel->m_ClipBox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
......
...@@ -243,8 +243,6 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ) ...@@ -243,8 +243,6 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
int hotkey = 0; int hotkey = 0;
double scalar = screen->GetScalingFactor(); double scalar = screen->GetScalingFactor();
ActiveScreen = screen;
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
...@@ -339,8 +337,6 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ) ...@@ -339,8 +337,6 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
int hotkey = 0; int hotkey = 0;
double scalar = screen->GetScalingFactor(); double scalar = screen->GetScalingFactor();
ActiveScreen = screen;
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
...@@ -434,8 +430,6 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ) ...@@ -434,8 +430,6 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
int hotkey = 0; int hotkey = 0;
double scalar = screen->GetScalingFactor(); double scalar = screen->GetScalingFactor();
ActiveScreen = screen;
curpos = screen->m_MousePosition; curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur; oldpos = screen->m_Curseur;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
// Keys for configuration // Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" ) #define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
extern BASE_SCREEN* ActiveScreen;
#define WIDTH_MAX_VALUE 100 #define WIDTH_MAX_VALUE 100
#define WIDTH_MIN_VALUE 1 #define WIDTH_MIN_VALUE 1
...@@ -125,7 +124,6 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) ...@@ -125,7 +124,6 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
schframe->m_CurrentSheet->UpdateAllScreenReferences(); schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount(); schframe->SetSheetNumberAndCount();
schscreen = schframe->m_CurrentSheet->LastScreen(); schscreen = schframe->m_CurrentSheet->LastScreen();
ActiveScreen = schscreen;
} }
else // Should not happen else // Should not happen
return; return;
...@@ -169,8 +167,6 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) ...@@ -169,8 +167,6 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
msg += wxT( "\n" ); msg += wxT( "\n" );
m_MessagesBox->AppendText( msg ); m_MessagesBox->AppendText( msg );
} }
ActiveScreen = oldscreen;
} }
......
...@@ -820,8 +820,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -820,8 +820,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
if( m_Cmp->m_Flags == 0 ) if( m_Cmp->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED ); m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
INSTALL_DC( dc, m_Parent->DrawPanel ); INSTALL_UNBUFFERED_DC( dc, m_Parent->DrawPanel );
m_Cmp->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), g_XorMode ); m_Cmp->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), g_XorMode );
// Initialize field values to default values found in library: // Initialize field values to default values found in library:
......
...@@ -197,7 +197,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent ) ...@@ -197,7 +197,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
if( m_CurrentText->m_Flags == 0 ) if( m_CurrentText->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED ); m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED );
m_Parent->DrawPanel->PostDirtyRect( m_CurrentText->GetBoundingBox() ); m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
text = m_textLabel->GetValue(); text = m_textLabel->GetValue();
if( !text.IsEmpty() ) if( !text.IsEmpty() )
...@@ -235,7 +235,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent ) ...@@ -235,7 +235,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
if( (m_CurrentText->m_Flags & IS_NEW) != 0 ) if( (m_CurrentText->m_Flags & IS_NEW) != 0 )
g_DefaultTextLabelSize = m_CurrentText->m_Size.x; g_DefaultTextLabelSize = m_CurrentText->m_Size.x;
m_Parent->DrawPanel->PostDirtyRect( m_CurrentText->GetBoundingBox() ); m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentText->GetBoundingBox() );
m_Parent->DrawPanel->MouseToCursorSchema(); m_Parent->DrawPanel->MouseToCursorSchema();
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
...@@ -172,12 +172,11 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) ...@@ -172,12 +172,11 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
{ {
sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() ); sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() );
*m_Parent->m_CurrentSheet = *sheet; *m_Parent->m_CurrentSheet = *sheet;
ActiveScreen = m_Parent->m_CurrentSheet->LastScreen();
m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
} }
sheet->LastScreen()->m_Curseur = pos; sheet->LastScreen()->m_Curseur = pos;
m_Parent->Recadre_Trace( true ); m_Parent->RedrawScreen( true );
} }
......
...@@ -145,7 +145,6 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -145,7 +145,6 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
{ {
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent; SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent;
SCH_SCREEN* screen = schframe->GetScreen(); SCH_SCREEN* screen = schframe->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet(); SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet();
wxString PlotFileName; wxString PlotFileName;
Ki_PageDescr* PlotSheet; Ki_PageDescr* PlotSheet;
...@@ -168,27 +167,29 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -168,27 +167,29 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
{ {
if( sheetpath == NULL ) if( sheetpath == NULL )
break; break;
list.Clear(); list.Clear();
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{ {
schframe->m_CurrentSheet = &list; schframe->m_CurrentSheet = &list;
schframe->m_CurrentSheet->UpdateAllScreenReferences(); schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount(); schframe->SetSheetNumberAndCount();
screen = schframe->m_CurrentSheet->LastScreen(); screen = schframe->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
} }
else // Should not happen else // Should not happen
return; return;
sheetpath = SheetList.GetNext(); sheetpath = SheetList.GetNext();
} }
PlotSheet = screen->m_CurrentSheetDesc; PlotSheet = screen->m_CurrentSheetDesc;
double scale = 10; double scale = 10;
plot_offset.x = 0; plot_offset.x = 0;
plot_offset.y = 0; plot_offset.y = 0;
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
".dxf" );
PlotOneSheetDXF( PlotFileName, screen, PlotSheet, plot_offset, scale ); PlotOneSheetDXF( PlotFileName, screen, PlotSheet, plot_offset, scale );
...@@ -196,7 +197,6 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -196,7 +197,6 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
break; break;
} }
ActiveScreen = oldscreen;
schframe->m_CurrentSheet = oldsheetpath; schframe->m_CurrentSheet = oldsheetpath;
schframe->m_CurrentSheet->UpdateAllScreenReferences(); schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount(); schframe->SetSheetNumberAndCount();
...@@ -204,10 +204,10 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( ) ...@@ -204,10 +204,10 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
SCH_SCREEN* screen, SCH_SCREEN* screen,
Ki_PageDescr* sheet, Ki_PageDescr* sheet,
wxPoint plot_offset, wxPoint plot_offset,
double scale ) double scale )
{ {
wxString msg; wxString msg;
......
...@@ -208,6 +208,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( ) ...@@ -208,6 +208,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( )
EESCHEMA_INTERNAL_UNIT); EESCHEMA_INTERNAL_UNIT);
if( g_HPGL_Pen_Descr.m_Pen_Diam > 100 ) if( g_HPGL_Pen_Descr.m_Pen_Diam > 100 )
g_HPGL_Pen_Descr.m_Pen_Diam = 100; g_HPGL_Pen_Descr.m_Pen_Diam = 100;
if( g_HPGL_Pen_Descr.m_Pen_Diam < 1 ) if( g_HPGL_Pen_Descr.m_Pen_Diam < 1 )
g_HPGL_Pen_Descr.m_Pen_Diam = 1; g_HPGL_Pen_Descr.m_Pen_Diam = 1;
} }
...@@ -216,8 +217,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( ) ...@@ -216,8 +217,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( )
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenSpeed( ) void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenSpeed( )
{ {
g_HPGL_Pen_Descr.m_Pen_Speed = m_penSpeedCtrl->GetValue(); g_HPGL_Pen_Descr.m_Pen_Speed = m_penSpeedCtrl->GetValue();
if( g_HPGL_Pen_Descr.m_Pen_Speed > 40 ) if( g_HPGL_Pen_Descr.m_Pen_Speed > 40 )
g_HPGL_Pen_Descr.m_Pen_Speed = 40; g_HPGL_Pen_Descr.m_Pen_Speed = 40;
if( g_HPGL_Pen_Descr.m_Pen_Speed < 1 ) if( g_HPGL_Pen_Descr.m_Pen_Speed < 1 )
g_HPGL_Pen_Descr.m_Pen_Speed = 1; g_HPGL_Pen_Descr.m_Pen_Speed = 1;
} }
...@@ -226,8 +229,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenSpeed( ) ...@@ -226,8 +229,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenSpeed( )
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenNum( ) void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenNum( )
{ {
g_HPGL_Pen_Descr.m_Pen_Num = m_penNumCtrl->GetValue(); g_HPGL_Pen_Descr.m_Pen_Num = m_penNumCtrl->GetValue();
if( g_HPGL_Pen_Descr.m_Pen_Num > 8 ) if( g_HPGL_Pen_Descr.m_Pen_Num > 8 )
g_HPGL_Pen_Descr.m_Pen_Num = 8; g_HPGL_Pen_Descr.m_Pen_Num = 8;
if( g_HPGL_Pen_Descr.m_Pen_Num < 1 ) if( g_HPGL_Pen_Descr.m_Pen_Num < 1 )
g_HPGL_Pen_Descr.m_Pen_Num = 1; g_HPGL_Pen_Descr.m_Pen_Num = 1;
} }
...@@ -258,8 +263,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll ) ...@@ -258,8 +263,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll )
* selected sheet * selected sheet
*/ */
void DIALOG_PLOT_SCHEMATIC_HPGL::ReturnSheetDims( BASE_SCREEN* screen, void DIALOG_PLOT_SCHEMATIC_HPGL::ReturnSheetDims( BASE_SCREEN* screen,
wxSize& SheetSize, wxSize& SheetSize,
wxPoint& SheetOffset ) wxPoint& SheetOffset )
{ {
Ki_PageDescr* PlotSheet; Ki_PageDescr* PlotSheet;
...@@ -277,7 +282,6 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh ...@@ -277,7 +282,6 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
{ {
wxString PlotFileName; wxString PlotFileName;
SCH_SCREEN* screen = m_Parent->GetScreen(); SCH_SCREEN* screen = m_Parent->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* sheetpath, * oldsheetpath = m_Parent->GetSheet(); SCH_SHEET_PATH* sheetpath, * oldsheetpath = m_Parent->GetSheet();
Ki_PageDescr* PlotSheet; Ki_PageDescr* PlotSheet;
wxSize SheetSize; wxSize SheetSize;
...@@ -300,46 +304,47 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh ...@@ -300,46 +304,47 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
{ {
if( sheetpath == NULL ) if( sheetpath == NULL )
break; break;
list.Clear(); list.Clear();
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{ {
m_Parent->m_CurrentSheet = &list; m_Parent->m_CurrentSheet = &list;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount(); m_Parent->SetSheetNumberAndCount();
screen = m_Parent->m_CurrentSheet->LastScreen(); screen = m_Parent->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
} }
else // Should not happen else // Should not happen
return; return;
sheetpath = SheetList.GetNext(); sheetpath = SheetList.GetNext();
} }
ReturnSheetDims( screen, SheetSize, SheetOffset ); ReturnSheetDims( screen, SheetSize, SheetOffset );
/* Calculation of conversion scales. */ /* Calculation of conversion scales. */
if( HPGL_SheetSize ) if( HPGL_SheetSize )
PlotSheet = Plot_sheet_list[HPGL_SheetSize]; PlotSheet = Plot_sheet_list[HPGL_SheetSize];
else else
PlotSheet = screen->m_CurrentSheetDesc; PlotSheet = screen->m_CurrentSheetDesc;
/* 10x because eeschema works in mils, not decimals */ /* 10x because eeschema works in mils, not decimals */
double plot_scale = 10 * (double) PlotSheet->m_Size.x / double plot_scale = 10 * (double) PlotSheet->m_Size.x / (double) SheetSize.x;
(double) SheetSize.x;
/* Calculate offsets */ /* Calculate offsets */
PlotOffset.x = -SheetOffset.x; PlotOffset.x = -SheetOffset.x;
PlotOffset.y = -SheetOffset.y; PlotOffset.y = -SheetOffset.y;
PlotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + PlotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
wxT( ".plt" );
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
Plot_1_Page_HPGL( PlotFileName, screen, PlotSheet, PlotOffset, Plot_1_Page_HPGL( PlotFileName, screen, PlotSheet, PlotOffset, plot_scale );
plot_scale );
SetLocaleTo_Default(); SetLocaleTo_Default();
if( !aPlotAll ) if( !aPlotAll )
break; break;
} }
ActiveScreen = oldscreen;
m_Parent->m_CurrentSheet = oldsheetpath; m_Parent->m_CurrentSheet = oldsheetpath;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount(); m_Parent->SetSheetNumberAndCount();
...@@ -347,10 +352,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh ...@@ -347,10 +352,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName, void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
SCH_SCREEN* screen, SCH_SCREEN* screen,
Ki_PageDescr* sheet, Ki_PageDescr* sheet,
wxPoint& offset, wxPoint& offset,
double plot_scale ) double plot_scale )
{ {
wxString msg; wxString msg;
...@@ -383,6 +388,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName, ...@@ -383,6 +388,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
plotter->start_plot( output_file ); plotter->start_plot( output_file );
plotter->set_color( BLACK ); plotter->set_color( BLACK );
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen ); m_Parent->PlotWorkSheet( plotter, screen );
......
...@@ -173,7 +173,6 @@ void DIALOG_PLOT_SCHEMATIC_PS::initOptVars() ...@@ -173,7 +173,6 @@ void DIALOG_PLOT_SCHEMATIC_PS::initOptVars()
void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
{ {
SCH_SCREEN* screen = m_Parent->GetScreen(); SCH_SCREEN* screen = m_Parent->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH* oldsheetpath = m_Parent->GetSheet(); // sheetpath is saved here SCH_SHEET_PATH* oldsheetpath = m_Parent->GetSheet(); // sheetpath is saved here
wxString plotFileName; wxString plotFileName;
...@@ -198,20 +197,24 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() ...@@ -198,20 +197,24 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
{ {
if( sheetpath == NULL ) if( sheetpath == NULL )
break; break;
list.Clear(); list.Clear();
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{ {
m_Parent->m_CurrentSheet = &list; m_Parent->m_CurrentSheet = &list;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount(); m_Parent->SetSheetNumberAndCount();
screen = m_Parent->m_CurrentSheet->LastScreen(); screen = m_Parent->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
} }
else // Should not happen else // Should not happen
return; return;
sheetpath = SheetList.GetNext(); sheetpath = SheetList.GetNext();
} }
actualPage = screen->m_CurrentSheetDesc; actualPage = screen->m_CurrentSheetDesc;
switch( m_pageSizeSelect ) switch( m_pageSizeSelect )
{ {
case PAGE_SIZE_A: case PAGE_SIZE_A:
...@@ -243,7 +246,6 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile() ...@@ -243,7 +246,6 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
break; break;
} }
ActiveScreen = oldscreen;
m_Parent->m_CurrentSheet = oldsheetpath; m_Parent->m_CurrentSheet = oldsheetpath;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount(); m_Parent->SetSheetNumberAndCount();
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
bool HasPage( int page ); bool HasPage( int page );
bool OnBeginDocument( int startPage, int endPage ); bool OnBeginDocument( int startPage, int endPage );
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ); void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
void DrawPage(); void DrawPage( SCH_SCREEN* aScreen );
}; };
...@@ -227,7 +227,6 @@ bool SCH_PRINTOUT::OnPrintPage( int page ) ...@@ -227,7 +227,6 @@ bool SCH_PRINTOUT::OnPrintPage( int page )
parent->AppendMsgPanel( msg, wxEmptyString, CYAN ); parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
SCH_SCREEN* screen = parent->GetScreen(); SCH_SCREEN* screen = parent->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* oldsheetpath = parent->GetSheet(); SCH_SHEET_PATH* oldsheetpath = parent->GetSheet();
SCH_SHEET_PATH list; SCH_SHEET_PATH list;
SCH_SHEET_LIST SheetList( NULL ); SCH_SHEET_LIST SheetList( NULL );
...@@ -248,9 +247,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page ) ...@@ -248,9 +247,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page )
if( screen == NULL ) if( screen == NULL )
return false; return false;
ActiveScreen = screen; DrawPage( screen );
DrawPage();
ActiveScreen = oldscreen;
parent->m_CurrentSheet = oldsheetpath; parent->m_CurrentSheet = oldsheetpath;
parent->m_CurrentSheet->UpdateAllScreenReferences(); parent->m_CurrentSheet->UpdateAllScreenReferences();
parent->SetSheetNumberAndCount(); parent->SetSheetNumberAndCount();
...@@ -259,8 +256,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page ) ...@@ -259,8 +256,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page )
} }
void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo )
int* selPageFrom, int* selPageTo )
{ {
*minPage = *selPageFrom = 1; *minPage = *selPageFrom = 1;
*maxPage = *selPageTo = g_RootSheet->CountSheets(); *maxPage = *selPageTo = g_RootSheet->CountSheets();
...@@ -306,7 +302,7 @@ bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage ) ...@@ -306,7 +302,7 @@ bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage )
/* /*
* This is the real print function: print the active screen * This is the real print function: print the active screen
*/ */
void SCH_PRINTOUT::DrawPage() void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
{ {
int oldZoom; int oldZoom;
wxPoint tmp_startvisu; wxPoint tmp_startvisu;
...@@ -321,15 +317,12 @@ void SCH_PRINTOUT::DrawPage() ...@@ -321,15 +317,12 @@ void SCH_PRINTOUT::DrawPage()
wxBusyCursor dummy; wxBusyCursor dummy;
/* Save current scale factor, offsets, and clip box. */ /* Save current scale factor, offsets, and clip box. */
tmp_startvisu = ActiveScreen->m_StartVisu; tmp_startvisu = aScreen->m_StartVisu;
oldZoom = ActiveScreen->GetZoom(); oldZoom = aScreen->GetZoom();
old_org = ActiveScreen->m_DrawOrg; old_org = aScreen->m_DrawOrg;
oldClipBox = panel->m_ClipBox; oldClipBox = panel->m_ClipBox;
/* Change scale factor, offsets, and clip box to print the whole page. */ /* Change scale factor, offsets, and clip box to print the whole page. */
ActiveScreen->SetScalingFactor( 1.0 );
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) ); panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ); panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
...@@ -343,8 +336,9 @@ void SCH_PRINTOUT::DrawPage() ...@@ -343,8 +336,9 @@ void SCH_PRINTOUT::DrawPage()
wxBitmap psuedoBitmap( 1, 1 ); wxBitmap psuedoBitmap( 1, 1 );
wxMemoryDC memDC; wxMemoryDC memDC;
memDC.SelectObject( psuedoBitmap ); memDC.SelectObject( psuedoBitmap );
( (SCH_SCREEN*) ActiveScreen )->Draw( panel, &memDC, GR_DEFAULT_DRAWMODE ); aScreen->Draw( panel, &memDC, GR_DEFAULT_DRAWMODE );
parent->TraceWorkSheet( &memDC, ActiveScreen, g_DrawDefaultLineThickness ); parent->TraceWorkSheet( &memDC, aScreen, g_DrawDefaultLineThickness );
wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ), wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() ); memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );
...@@ -356,7 +350,7 @@ void SCH_PRINTOUT::DrawPage() ...@@ -356,7 +350,7 @@ void SCH_PRINTOUT::DrawPage()
} }
else else
{ {
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; SheetSize = aScreen->m_CurrentSheetDesc->m_Size;
FitThisSizeToPaper( SheetSize ); FitThisSizeToPaper( SheetSize );
fitRect = GetLogicalPaperRect(); fitRect = GetLogicalPaperRect();
} }
...@@ -369,21 +363,22 @@ void SCH_PRINTOUT::DrawPage() ...@@ -369,21 +363,22 @@ void SCH_PRINTOUT::DrawPage()
if( parent->GetPrintMonochrome() ) if( parent->GetPrintMonochrome() )
GRForceBlackPen( true ); GRForceBlackPen( true );
ActiveScreen->m_IsPrinting = true; aScreen->m_IsPrinting = true;
int bg_color = g_DrawBgColor; int bg_color = g_DrawBgColor;
( ( SCH_SCREEN* ) ActiveScreen )->Draw( panel, dc, GR_DEFAULT_DRAWMODE ); aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference ) if( printReference )
parent->TraceWorkSheet( dc, ActiveScreen, g_DrawDefaultLineThickness ); parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness );
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
ActiveScreen->m_IsPrinting = false; aScreen->m_IsPrinting = false;
panel->m_ClipBox = oldClipBox; panel->m_ClipBox = oldClipBox;
GRForceBlackPen( false ); GRForceBlackPen( false );
ActiveScreen->m_StartVisu = tmp_startvisu; aScreen->m_StartVisu = tmp_startvisu;
ActiveScreen->m_DrawOrg = old_org; aScreen->m_DrawOrg = old_org;
ActiveScreen->SetZoom( oldZoom ); aScreen->SetZoom( oldZoom );
} }
...@@ -50,8 +50,6 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -50,8 +50,6 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( GetScreen() == NULL ) if( GetScreen() == NULL )
return; return;
ActiveScreen = GetScreen();
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
GetScreen()->Draw( DrawPanel, DC, GR_DEFAULT_DRAWMODE ); GetScreen()->Draw( DrawPanel, DC, GR_DEFAULT_DRAWMODE );
......
...@@ -159,7 +159,6 @@ bool WinEDA_App::OnInit() ...@@ -159,7 +159,6 @@ bool WinEDA_App::OnInit()
SetupServerFunction( RemoteCommand ); SetupServerFunction( RemoteCommand );
} }
ActiveScreen = frame->GetScreen();
frame->Zoom_Automatique( TRUE ); frame->Zoom_Automatique( TRUE );
/* Load file specified in the command line. */ /* Load file specified in the command line. */
......
...@@ -27,7 +27,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) ...@@ -27,7 +27,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
if( !curr_item || curr_item->m_Flags ) if( !curr_item || curr_item->m_Flags )
return; return;
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( curr_item->Type() ) switch( curr_item->Type() )
{ {
......
...@@ -61,13 +61,12 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) ...@@ -61,13 +61,12 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
{ {
sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() ); sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheetFoundIn; *m_CurrentSheet = *sheetFoundIn;
ActiveScreen = m_CurrentSheet->LastScreen();
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
} }
sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos; sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos;
Recadre_Trace( TRUE ); RedrawScreen( TRUE );
wxString path = sheetFoundIn->Path(); wxString path = sheetFoundIn->Path();
wxString units = GetAbbreviatedUnitsLabel(); wxString units = GetAbbreviatedUnitsLabel();
...@@ -184,7 +183,6 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -184,7 +183,6 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
{ {
sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheet; *m_CurrentSheet = *sheet;
ActiveScreen = m_CurrentSheet->LastScreen();
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
DoCenterAndRedraw = TRUE; DoCenterAndRedraw = TRUE;
} }
...@@ -215,10 +213,10 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -215,10 +213,10 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
#undef MARGIN #undef MARGIN
if( DoCenterAndRedraw ) if( DoCenterAndRedraw )
Recadre_Trace( mouseWarp ); RedrawScreen( mouseWarp );
else else
{ {
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
...@@ -329,13 +327,12 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) ...@@ -329,13 +327,12 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event )
{ {
sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() ); sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheetFoundIn; *m_CurrentSheet = *sheetFoundIn;
ActiveScreen = m_CurrentSheet->LastScreen();
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
} }
// sheetFoundIn->LastScreen()->m_Curseur = lastItem->GetBoundingBox().Centre(); // sheetFoundIn->LastScreen()->m_Curseur = lastItem->GetBoundingBox().Centre();
sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition; sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition;
Recadre_Trace( true ); RedrawScreen( true );
msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable(); msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable();
SetStatusText( msg ); SetStatusText( msg );
......
...@@ -259,7 +259,7 @@ void SCH_EDIT_FRAME::CmpRotationMiroir( SCH_COMPONENT* DrawComponent, wxDC* DC, ...@@ -259,7 +259,7 @@ void SCH_EDIT_FRAME::CmpRotationMiroir( SCH_COMPONENT* DrawComponent, wxDC* DC,
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
else else
{ {
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( DrawComponent->GetBoundingBox() );
} }
} }
...@@ -441,11 +441,11 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC ) ...@@ -441,11 +441,11 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC )
// switch from normal mode to xor mode for the duration of the move, first // switch from normal mode to xor mode for the duration of the move, first
// by erasing fully any "normal drawing mode" primitives with the // by erasing fully any "normal drawing mode" primitives with the
// PostDirtyRect(), then by drawing the first time in xor mode so that // RefreshDrawingRect(), then by drawing the first time in xor mode so that
// subsequent xor drawing modes will fully erase this first copy. // subsequent xor drawing modes will fully erase this first copy.
Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only
DrawPanel->PostDirtyRect( Component->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Component->GetBoundingBox() );
Component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); Component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
......
...@@ -260,16 +260,14 @@ void SCH_EDIT_FRAME::InstallPreviousSheet() ...@@ -260,16 +260,14 @@ void SCH_EDIT_FRAME::InstallPreviousSheet()
ClearMsgPanel(); ClearMsgPanel();
//make a copy for testing purposes. //make a copy for testing purposes.
SCH_SHEET_PATH listtemp = *m_CurrentSheet; m_CurrentSheet->Pop();
listtemp.Pop();
if( listtemp.LastScreen() == NULL ) if( m_CurrentSheet->LastScreen() == NULL )
{ {
DisplayError( this, wxT( "InstallPreviousScreen() Error: Sheet not found" ) ); DisplayError( this, wxT( "InstallPreviousScreen() Error: Sheet not found" ) );
return; return;
} }
m_CurrentSheet->Pop();
UpdateScreenFromSheet( this ); UpdateScreenFromSheet( this );
} }
...@@ -286,6 +284,7 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet ) ...@@ -286,6 +284,7 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet )
{ {
DisplayError( this, wxT( "InstallNextScreen() error" ) ); return; DisplayError( this, wxT( "InstallNextScreen() error" ) ); return;
} }
m_CurrentSheet->Push( Sheet ); m_CurrentSheet->Push( Sheet );
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
ClearMsgPanel(); ClearMsgPanel();
...@@ -298,41 +297,33 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet ) ...@@ -298,41 +297,33 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet )
*/ */
static bool UpdateScreenFromSheet( SCH_EDIT_FRAME* frame ) static bool UpdateScreenFromSheet( SCH_EDIT_FRAME* frame )
{ {
SCH_SCREEN* NewScreen; if( !frame->m_CurrentSheet->LastScreen() )
NewScreen = frame->m_CurrentSheet->LastScreen();
if( !NewScreen )
{ {
DisplayError( frame, wxT( "Screen not found for this sheet" ) ); DisplayError( frame, wxT( "Screen not found for this sheet" ) );
return false; return false;
} }
SCH_SCREEN* screen = frame->m_CurrentSheet->LastScreen();
// Reset display settings of the new screen // Reset display settings of the new screen
// Assumes m_CurrentSheet has already been updated. // Assumes m_CurrentSheet has already been updated.
frame->ClearMsgPanel(); frame->ClearMsgPanel();
frame->DrawPanel->SetScrollbars( NewScreen->m_ScrollPixelsPerUnitX,
NewScreen->m_ScrollPixelsPerUnitY,
NewScreen->m_ScrollbarNumber.x,
NewScreen->m_ScrollbarNumber.y,
NewScreen->m_ScrollbarPos.x,
NewScreen->m_ScrollbarPos.y, TRUE );
// update the References // update the References
frame->m_CurrentSheet->UpdateAllScreenReferences(); frame->m_CurrentSheet->UpdateAllScreenReferences();
frame->SetSheetNumberAndCount(); frame->SetSheetNumberAndCount();
frame->DrawPanel->m_CanStartBlock = -1; frame->DrawPanel->m_CanStartBlock = -1;
ActiveScreen = frame->m_CurrentSheet->LastScreen();
if( NewScreen->m_FirstRedraw ) if( screen->m_FirstRedraw )
{ {
NewScreen->m_FirstRedraw = FALSE; screen->m_FirstRedraw = false;
frame->Zoom_Automatique( TRUE ); frame->Zoom_Automatique( true );
} }
else else
{ {
frame->DrawPanel->MouseToCursorSchema(); frame->DrawPanel->MouseToCursorSchema();
frame->RedrawScreen( true );
} }
frame->DrawPanel->Refresh();
return true; return true;
} }
...@@ -198,8 +198,6 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -198,8 +198,6 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( GetScreen() == NULL ) if( GetScreen() == NULL )
return; return;
ActiveScreen = GetScreen();
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
if( m_component ) if( m_component )
......
...@@ -640,7 +640,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -640,7 +640,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
...@@ -928,6 +928,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -928,6 +928,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
} }
...@@ -1072,7 +1073,7 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event ) ...@@ -1072,7 +1073,7 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
wxCHECK_RET( m_component != NULL, wxCHECK_RET( m_component != NULL,
wxT( "Cannot create new part from non-existant current part." ) ); wxT( "Cannot create new part from non-existant current part." ) );
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
EditField( &dc, &m_component->GetValueField() ); EditField( &dc, &m_component->GetValueField() );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
......
...@@ -167,7 +167,7 @@ void DeleteStruct( EDA_DRAW_PANEL* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -167,7 +167,7 @@ void DeleteStruct( EDA_DRAW_PANEL* panel, wxDC* DC, SCH_ITEM* DrawStruct )
{ {
screen->RemoveFromDrawList( DrawStruct ); screen->RemoveFromDrawList( DrawStruct );
panel->PostDirtyRect( DrawStruct->GetBoundingBox() ); panel->RefreshDrawingRect( DrawStruct->GetBoundingBox() );
/* Unlink the structure */ /* Unlink the structure */
DrawStruct->SetNext( 0 ); DrawStruct->SetNext( 0 );
......
...@@ -531,6 +531,6 @@ private: ...@@ -531,6 +531,6 @@ private:
}; };
typedef boost::ptr_vector< SCH_SHEET > SCH_SHEETS; typedef std::vector< SCH_SHEET* > SCH_SHEETS;
#endif /* CLASS_DRAWSHEET_H */ #endif /* CLASS_DRAWSHEET_H */
...@@ -448,23 +448,22 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData, ...@@ -448,23 +448,22 @@ SCH_ITEM* SCH_SHEET_PATH::MatchNextItem( wxFindReplaceData& aSearchData,
} }
bool SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 ) SCH_SHEET_PATH& SCH_SHEET_PATH::operator=( const SCH_SHEET_PATH& d1 )
{ {
if( this == &d1 ) // Self assignment is bad!
return *this;
m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets;
unsigned i; unsigned i;
for( i = 0; i < m_numSheets; i++ ) for( i = 0; i < m_numSheets; i++ )
{
m_sheets[i] = d1.m_sheets[i]; m_sheets[i] = d1.m_sheets[i];
}
for( ; i < DSLSZ; i++ ) for( ; i < DSLSZ; i++ )
{
m_sheets[i] = 0; m_sheets[i] = 0;
}
return true; return *this;
} }
...@@ -483,29 +482,6 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const ...@@ -483,29 +482,6 @@ bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const
} }
bool SCH_SHEET_PATH::operator!=( const SCH_SHEET_PATH& d1 ) const
{
if( m_numSheets != d1.m_numSheets )
return true;
for( unsigned i = 0; i < m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
{
/*
printf( "micompare this:'%s' d1:'%s'\n",
CONV_TO_UTF8( PathHumanReadable() ),
CONV_TO_UTF8( d1.PathHumanReadable() ) );
*/
return true;
}
}
return false;
}
/*********************************************************************/ /*********************************************************************/
/* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */ /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */
/*********************************************************************/ /*********************************************************************/
...@@ -635,6 +611,28 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) ...@@ -635,6 +611,28 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
} }
bool SCH_SHEET_LIST::IsModified()
{
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() )
{
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
return true;
}
return false;
}
void SCH_SHEET_LIST::ClearModifyStatus()
{
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() )
{
if( sheet->LastScreen() )
sheet->LastScreen()->ClrModify();
}
}
void SCH_SHEET_LIST::AnnotatePowerSymbols() void SCH_SHEET_LIST::AnnotatePowerSymbols()
{ {
int ref = 1; int ref = 1;
......
...@@ -240,11 +240,11 @@ public: ...@@ -240,11 +240,11 @@ public:
SCH_ITEM* MatchNextItem( wxFindReplaceData& aSearchData, SCH_ITEM* aLastItem, SCH_ITEM* MatchNextItem( wxFindReplaceData& aSearchData, SCH_ITEM* aLastItem,
wxPoint * aFindLocation ); wxPoint * aFindLocation );
bool operator=( const SCH_SHEET_PATH& d1 ); SCH_SHEET_PATH& operator=( const SCH_SHEET_PATH& d1 );
bool operator==( const SCH_SHEET_PATH& d1 ) const; bool operator==( const SCH_SHEET_PATH& d1 ) const;
bool operator!=( const SCH_SHEET_PATH& d1 ) const; bool operator!=( const SCH_SHEET_PATH& d1 ) const { return !( *this == d1 ) ; }
}; };
...@@ -336,6 +336,15 @@ public: ...@@ -336,6 +336,15 @@ public:
*/ */
SCH_SHEET_PATH* GetSheet( int aIndex ); SCH_SHEET_PATH* GetSheet( int aIndex );
/**
* Function IsModified
* checks the entire hierachy for any modifications.
* @returns True if the hierarchy is modified otherwise false.
*/
bool IsModified();
void ClearModifyStatus();
/** /**
* Function AnnotatePowerSymbols * Function AnnotatePowerSymbols
* clear and annotates the entire hierarchy of the sheet path list. * clear and annotates the entire hierarchy of the sheet path list.
......
...@@ -156,7 +156,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -156,7 +156,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
case ID_HIERARCHY: case ID_HIERARCHY:
...@@ -403,7 +404,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -403,7 +404,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( sheet, UR_CHANGED ); SaveCopyInUndoList( sheet, UR_CHANGED );
sheet->CleanupSheet(); sheet->CleanupSheet();
OnModify(); OnModify();
DrawPanel->PostDirtyRect( sheet->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
} }
break; break;
......
...@@ -346,23 +346,12 @@ void SCH_EDIT_FRAME::CreateScreens() ...@@ -346,23 +346,12 @@ void SCH_EDIT_FRAME::CreateScreens()
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
SCH_SHEET_PATH* sheet; if( m_LibeditFrame && !m_LibeditFrame->Close() ) // Can close component editor?
return;
if( m_LibeditFrame ) // Can close component editor ?
{
if( !m_LibeditFrame->Close() )
return;
}
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) if( SheetList.IsModified() )
{
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
break;
}
if( sheet )
{ {
wxMessageDialog dialog( this, wxMessageDialog dialog( this,
_( "Schematic modified, Save before exit ?" ), _( "Schematic modified, Save before exit ?" ),
...@@ -385,15 +374,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -385,15 +374,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
} }
for( sheet = SheetList.GetFirst(); SheetList.ClearModifyStatus();
sheet != NULL;
sheet = SheetList.GetNext() )
{
if( sheet->LastScreen() )
{
sheet->LastScreen()->ClrModify();
}
}
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty()
&& (g_RootSheet->GetScreen()->GetDrawItems() != NULL) ) && (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
...@@ -733,7 +714,6 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) ...@@ -733,7 +714,6 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
wxT( "Library Editor" ), wxT( "Library Editor" ),
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
ActiveScreen = GetBaseScreen();
m_LibeditFrame->AdjustScrollBars(); m_LibeditFrame->AdjustScrollBars();
} }
} }
......
...@@ -271,7 +271,7 @@ void SCH_EDIT_FRAME::DeleteSheetLabel( bool aRedraw, SCH_SHEET_PIN* aSheetLabelT ...@@ -271,7 +271,7 @@ void SCH_EDIT_FRAME::DeleteSheetLabel( bool aRedraw, SCH_SHEET_PIN* aSheetLabelT
parent->RemoveLabel( aSheetLabelToDel ); parent->RemoveLabel( aSheetLabelToDel );
if( aRedraw ) if( aRedraw )
DrawPanel->PostDirtyRect( parent->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( parent->GetBoundingBox() );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
......
...@@ -237,6 +237,6 @@ void LIB_EDIT_FRAME::PlaceAncre() ...@@ -237,6 +237,6 @@ void LIB_EDIT_FRAME::PlaceAncre()
/* Redraw the symbol */ /* Redraw the symbol */
GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0; GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0;
Recadre_Trace( TRUE ); RedrawScreen( TRUE );
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
...@@ -259,8 +259,6 @@ void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -259,8 +259,6 @@ void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
wxString msg; wxString msg;
wxString tmp; wxString tmp;
ActiveScreen = GetScreen();
lib = CMP_LIBRARY::FindLibrary( m_libraryName ); lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib == NULL ) if( lib == NULL )
......
...@@ -78,11 +78,10 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -78,11 +78,10 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
wxBusyCursor dummy; wxBusyCursor dummy;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
int drawMode = -1; int drawMode = -1;
switch ( GetDisplayMode() ) switch ( GetDisplayMode() )
{ {
default: default:
......
...@@ -117,6 +117,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -117,6 +117,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
} }
INSTALL_DC( dc, DrawPanel ); INSTALL_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
case ID_EXIT: case ID_EXIT:
......
...@@ -96,8 +96,6 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) ...@@ -96,8 +96,6 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
wxFileName filename = aFullFileName; wxFileName filename = aFullFileName;
wxString currentPath; wxString currentPath;
ActiveScreen = GetScreen();
if( ! filename.IsOk() ) if( ! filename.IsOk() )
{ {
/* Standard gerber filetypes /* Standard gerber filetypes
...@@ -197,14 +195,11 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName ) ...@@ -197,14 +195,11 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
* 0 if file not read (cancellation of order ...) * 0 if file not read (cancellation of order ...)
* 1 if OK * 1 if OK
*/ */
static void LoadDCodeFile( WinEDA_GerberFrame* frame, static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileName )
const wxString& FullFileName )
{ {
wxString wildcard; wxString wildcard;
wxFileName fn = FullFileName; wxFileName fn = FullFileName;
ActiveScreen = frame->GetScreen();
if( !fn.IsOk() ) if( !fn.IsOk() )
{ {
wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ), wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ),
......
...@@ -152,7 +152,6 @@ END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father ...@@ -152,7 +152,6 @@ END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father
#endif #endif
SetBaseScreen( ScreenPcb ); SetBaseScreen( ScreenPcb );
ActiveScreen = ScreenPcb;
SetBoard( new BOARD( NULL, this ) ); SetBoard( new BOARD( NULL, this ) );
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first. GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
......
...@@ -93,7 +93,6 @@ bool WinEDA_App::OnInit() ...@@ -93,7 +93,6 @@ bool WinEDA_App::OnInit()
} }
ScreenPcb = new PCB_SCREEN(); ScreenPcb = new PCB_SCREEN();
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
ActiveScreen = ScreenPcb;
// read current setup and reopen last directory if no filename to open in // read current setup and reopen last directory if no filename to open in
// command line // command line
......
...@@ -44,7 +44,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -44,7 +44,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
GetBoard()->m_NbNodes = 0; GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0; GetBoard()->m_NbNoconnect = 0;
SetBaseScreen( ActiveScreen = ScreenPcb ); SetBaseScreen( ScreenPcb );
GetScreen()->Init(); GetScreen()->Init();
setActiveLayer(LAYER_N_BACK); setActiveLayer(LAYER_N_BACK);
syncLayerBox(); syncLayerBox();
......
...@@ -62,7 +62,6 @@ public: ...@@ -62,7 +62,6 @@ public:
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */ wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */
wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */
wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */
wxPoint m_MousePositionInPixels;
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid)
* in user units. * in user units.
* (coordinates from last reset position)*/ * (coordinates from last reset position)*/
...@@ -165,13 +164,6 @@ public: ...@@ -165,13 +164,6 @@ public:
wxSize ReturnPageSize( void ); wxSize ReturnPageSize( void );
virtual int GetInternalUnits( void ); virtual int GetInternalUnits( void );
/**
* Function CursorRealPosition
* @return the position in user units of location ScreenPos
* @param ScreenPos = the screen (in pixel) position co convert
*/
wxPoint CursorRealPosition( const wxPoint& ScreenPos );
/** /**
* Return the current cursor position in drawing coordinates. * Return the current cursor position in drawing coordinates.
* *
...@@ -301,16 +293,6 @@ public: ...@@ -301,16 +293,6 @@ public:
*/ */
void SetZoomList( const wxArrayInt& aZoomList ); void SetZoomList( const wxArrayInt& aZoomList );
int Scale( int coord );
double Scale( double coord );
void Scale( wxPoint& pt );
void Scale( wxSize& sz );
void Scale( wxRealPoint& sz );
int Unscale( int coord );
void Unscale( wxPoint& pt );
void Unscale( wxSize& sz );
bool SetNextZoom(); bool SetNextZoom();
bool SetPreviousZoom(); bool SetPreviousZoom();
bool SetFirstZoom(); bool SetFirstZoom();
......
...@@ -89,7 +89,6 @@ public: ...@@ -89,7 +89,6 @@ public:
} }
void OnPaint( wxPaintEvent& event ); void OnPaint( wxPaintEvent& event );
void OnSize( wxSizeEvent& event );
/** /**
* Function DrawBackGround * Function DrawBackGround
...@@ -128,7 +127,7 @@ public: ...@@ -128,7 +127,7 @@ public:
*/ */
void DrawGridAxis( wxDC* aDC, int aDrawMode ); void DrawGridAxis( wxDC* aDC, int aDrawMode );
void OnEraseBackground( wxEraseEvent& event ); void OnEraseBackground( wxEraseEvent& event ) { }
void OnActivate( wxActivateEvent& event ); void OnActivate( wxActivateEvent& event );
...@@ -141,7 +140,7 @@ public: ...@@ -141,7 +140,7 @@ public:
* update the boundary box. If wxDC coordinate manipulation is used, then * update the boundary box. If wxDC coordinate manipulation is used, then
* the scale factor and drawing logical offset is set. Then the base * the scale factor and drawing logical offset is set. Then the base
* method is called to set the DC device origin and user scale. This * method is called to set the DC device origin and user scale. This
* connects everything together to acheive the appropiate coordinate * connects everything together to achieve the appropriate coordinate
* manipulation using wxDC LogicalToDeviceXXX and DeviceToLogixalXXX * manipulation using wxDC LogicalToDeviceXXX and DeviceToLogixalXXX
* methods. This gets called automatically for a paint event. If you do * methods. This gets called automatically for a paint event. If you do
* any drawing outside the paint event, you must call DoPrepareDC manually. * any drawing outside the paint event, you must call DoPrepareDC manually.
...@@ -150,6 +149,18 @@ public: ...@@ -150,6 +149,18 @@ public:
*/ */
virtual void DoPrepareDC(wxDC& dc); virtual void DoPrepareDC(wxDC& dc);
/**
* Function DeviceToLogical
* converts \a aRect from device to drawing (logical) coordinates.
* <p>
* \a aRect must be in scrolled device units.
* <\p>
* @param aRect The rectangle to convert.
* @param aDC The device context used for the conversion.
* @return A rectangle converted to drawing units.
*/
wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC );
/* Mouse and keys events */ /* Mouse and keys events */
void OnMouseWheel( wxMouseEvent& event ); void OnMouseWheel( wxMouseEvent& event );
void OnMouseEvent( wxMouseEvent& event ); void OnMouseEvent( wxMouseEvent& event );
...@@ -171,7 +182,22 @@ public: ...@@ -171,7 +182,22 @@ public:
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
bool IsPointOnDisplay( wxPoint ref_pos ); bool IsPointOnDisplay( wxPoint ref_pos );
void SetBoundaryBox( wxDC* dc );
/**
* Function SetClipBox
* sets the clip box in drawing (logical) units from \a aRect in device units.
* <p>
* If \a aRect is NULL, then the entire visible area of the screen is used as the clip
* area. The clip box is used when drawing to determine which objects are not visible
* and do not need to be drawn.
* </p>
* @param aDc The device context use for drawing with the correct scale and
* offsets already configured. See DoPrepareDC().
* @param aRect The clip rectangle in device units or NULL for the entire visible area
* of the screen.
*/
void SetClipBox( wxDC& dc, const wxRect* aRect = NULL );
void ReDraw( wxDC* DC, bool erasebg = TRUE ); void ReDraw( wxDC* DC, bool erasebg = TRUE );
/** /**
...@@ -183,40 +209,18 @@ public: ...@@ -183,40 +209,18 @@ public:
/** /**
* Function CursorScreenPosition * Function CursorScreenPosition
* @return the curseur current position in pixels in the screen draw area * @return the cursor current position in pixels in the screen draw area
*/ */
wxPoint CursorScreenPosition(); wxPoint CursorScreenPosition();
/** /**
* Function PostDirtyRect * Function RefreshDrawingRect
* appends the given rectangle in pcb units to the DrawPanel's invalid * redraws the contents of \a aRect in drawing units. \a aRect is converted to
* region list so that very soon (but not immediately), this rectangle * screen coordinates and wxWindow::RefreshRect() is called to repaint the region.
* along with any other recently posted rectangles is redrawn. Conversion * @param aRect The rectangle to repaint.
* to pixels is done in here. * @param aEraseBackground Erases the background if true.
* @param aRect The rectangle to append, it must be orthogonal
* (vertical and horizontal edges only), and it must be [,) in nature,
* i.e. [pos, dim) == [inclusive, exclusive)
*/
void PostDirtyRect( EDA_Rect aRect );
/**
* Function ConvertPcbUnitsToPixelsUnits
* converts pos and size of the given EDA_Rect to pos and size in pixels,
* relative to the current draw area (origin 0,0 is the left top visible
* corner of draw area) according to the current scroll and zoom.
* @param aRect = the rectangle to convert
*/
void ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect );
/**
* Function ConvertPcbUnitsToPixelsUnits
* converts a given wxPoint position (in internal units) to units of
* pixels, relative to the current draw area (origin 0,0 is the left
* top visible
* corner of draw area) according to the current scroll and zoom.
* @param aPosition = the position to convert
*/ */
void ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition ); void RefreshDrawingRect( const EDA_Rect& aRect, bool aEraseBackground = true );
wxPoint GetScreenCenterRealPosition( void ); wxPoint GetScreenCenterRealPosition( void );
void MouseToCursorSchema(); void MouseToCursorSchema();
......
...@@ -45,9 +45,6 @@ typedef enum { ...@@ -45,9 +45,6 @@ typedef enum {
} GRLineStypeType; } GRLineStypeType;
int GRMapX( int x );
int GRMapY( int y );
class EDA_DRAW_PANEL; class EDA_DRAW_PANEL;
void GRSetDrawMode( wxDC* DC, int mode ); void GRSetDrawMode( wxDC* DC, int mode );
...@@ -68,8 +65,6 @@ void GRForceBlackPen( bool flagforce ); ...@@ -68,8 +65,6 @@ void GRForceBlackPen( bool flagforce );
*/ */
bool GetGRForceBlackPenState( void ); bool GetGRForceBlackPenState( void );
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int color );
void GRLine( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor ); void GRLine( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor );
void GRLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color ); void GRLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color );
void GRMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, void GRMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
......
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2007 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/** /**
* a helper to handle the real device context used in kicad * a helper to handle the real device context used in kicad
* @file kicad_device_context.h * @file kicad_device_context.h
...@@ -6,43 +32,89 @@ ...@@ -6,43 +32,89 @@
#ifndef __KICAD_DEVICE_CONTEXT_H__ #ifndef __KICAD_DEVICE_CONTEXT_H__
#define __KICAD_DEVICE_CONTEXT_H__ #define __KICAD_DEVICE_CONTEXT_H__
// Comment this line to use the standard wxClientDC #include <wx/dcbuffer.h>
// and uncomment to use buffered DC
// #define KICAD_USE_BUFFERED_DC // Currently under test
// Comment this line to use the standard wxPaintDC #if defined(KICAD_USE_BUFFERED_PAINTDC)
// and uncomment to use buffered PaintDC #undef KICAD_USE_BUFFERED_PAINTDC
#define KICAD_USE_BUFFERED_PAINTDC // Currently under test #endif
#if defined KICAD_USE_BUFFERED_DC || defined KICAD_USE_BUFFERED_PAINTDC #if defined(KICAD_USE_BUFFERED_DC)
#ifndef KICAD_USE_BUFFERED_PAINTDC #undef KICAD_USE_BUFFERED_DC
#define KICAD_USE_BUFFERED_PAINTDC #endif
#endif
#include <wx/dcbuffer.h> // wxWidgets defines the platforms where device context buffering is well behaved. These
// definitions take advantage of their experience in this area. See <wx/dcbuffer.h> for
// more information.
#if wxALWAYS_NATIVE_DOUBLE_BUFFER
#define KICAD_USE_BUFFERED_PAINTDC 1
#define KICAD_USE_BUFFERED_DC_HELPER 0
#define KICAD_USE_BUFFERED_DC 0
#else
#define KICAD_USE_BUFFERED_PAINTDC 1
#define KICAD_USE_BUFFERED_DC_HELPER 1
#define KICAD_USE_BUFFERED_DC 1
#endif #endif
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM
/**
* Class BUFFERED_DC_HELPER
* fixes a bug on Windows when using buffered device context.
*
* <p>
* When using buffered device context drawing in Windows, the user scaling must be set to 1
* and the logical offset must be set to zero before the bitmap blit operation occurs in
* the destructor of wxBufferdDC but after the normal drawing takes place.
* </p>
*/
class BUFFERED_DC_HELPER
{
public:
BUFFERED_DC_HELPER( wxBufferedDC* aDC )
: m_dc( aDC ) {}
virtual ~BUFFERED_DC_HELPER()
{
if( m_dc )
{
m_dc->SetLogicalOrigin( 0, 0 );
m_dc->SetUserScale( 1.0, 1.0 );
}
}
private:
wxBufferedDC* m_dc;
};
#if USE_WX_GRAPHICS_CONTEXT
#include <wx/dcgraph.h> #include <wx/dcgraph.h>
#endif #endif
// Macro used to declare a device context in kicad: // Macro used to declare a device context in kicad:
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM #if USE_WX_GRAPHICS_CONTEXT
//#pragma message( "INSTALL_DC is wxClientDC with wxGCDC" ) //#pragma message( "INSTALL_DC is wxClientDC with wxGCDC" )
#define INSTALL_DC(name,parent) \ #define INSTALL_DC( name, parent ) \
wxClientDC _cDC( parent ); \ wxClientDC _cDC( parent ); \
wxGCDC name(_cDC); \ wxGCDC name( _cDC ); \
parent->DoPrepareDC( name ); \ parent->DoPrepareDC( name ); \
name.GetGraphicsContext()->Translate( 0.5, 0.5 ); name.GetGraphicsContext()->Translate( 0.5, 0.5 );
#else #else
#ifdef KICAD_USE_BUFFERED_DC #if KICAD_USE_BUFFERED_DC && !KICAD_USE_BUFFERED_DC_HELPER
//#pragma message( "INSTALL_DC is wxClientDC with wxBufferedDC" ) //#pragma message( "INSTALL_DC is wxClientDC with wxBufferedDC" )
#define INSTALL_DC(name,parent) \ #define INSTALL_DC( name, parent ) \
wxClientDC _cDC( parent ); \ wxClientDC _cDC( parent ); \
wxBufferedDC name(&_cDC, _cDC.GetSize() ); \ wxBufferedDC name(&_cDC, _cDC.GetSize() ); \
parent->DoPrepareDC( name ); parent->DoPrepareDC( name );
#elif KICAD_USE_BUFFERED_DC && KICAD_USE_BUFFERED_DC_HELPER
//#pragma message( "INSTALL_DC is wxBufferedDC with BUFFERED_DC_HELPER" )
#define INSTALL_DC( name, parent ) \
wxClientDC _cDC( parent ); \
wxBufferedDC name(&_cDC, _cDC.GetSize() ); \
parent->DoPrepareDC( name ); \
BUFFERED_DC_HELPER helper( &name );
#else #else
//#pragma message( "INSTALL_DC is wxClientDC" ) //#pragma message( "INSTALL_DC is wxClientDC" )
#define INSTALL_DC(name,parent) \ #define INSTALL_DC( name, parent ) \
wxClientDC name( parent ); \ wxClientDC name( parent ); \
parent->DoPrepareDC( name ); parent->DoPrepareDC( name );
#endif #endif
...@@ -50,16 +122,22 @@ ...@@ -50,16 +122,22 @@
#if USE_WX_GRAPHICS_CONTEXT #if USE_WX_GRAPHICS_CONTEXT
//#pragma message( "INSTALL_PAINTDC is wxPaintDC with wxGCDC" ) //#pragma message( "INSTALL_PAINTDC is wxPaintDC with wxGCDC" )
#define INSTALL_PAINTDC(name,parent) \ #define INSTALL_PAINTDC( name, parent) \
wxPaintDC _pDC(parent); \ wxPaintDC _pDC( parent ); \
wxGCDC name(_pDC); \ wxGCDC name( _pDC ); \
parent->DoPrepareDC( name ); \ parent->DoPrepareDC( name ); \
name.GetGraphicsContext()->Translate( 0.5, 0.5 ); name.GetGraphicsContext()->Translate( 0.5, 0.5 );
#elif !defined( USE_WX_ZOOM ) && defined( KICAD_USE_BUFFERED_PAINTDC ) #elif KICAD_USE_BUFFERED_PAINTDC && !KICAD_USE_BUFFERED_DC_HELPER
//#pragma message( "INSTALL_PAINTDC is wxAutoBufferedPaintDC" ) //#pragma message( "INSTALL_PAINTDC is wxAutoBufferedPaintDC" )
#define INSTALL_PAINTDC(name,parent) \ #define INSTALL_PAINTDC( name, parent ) \
wxAutoBufferedPaintDC name(parent ); \ wxAutoBufferedPaintDC name( parent ); \
parent->DoPrepareDC( name ); parent->DoPrepareDC( name );
#elif KICAD_USE_BUFFERED_PAINTDC && KICAD_USE_BUFFERED_DC_HELPER
//#pragma message( "INSTALL_PAINTDC is wxBufferedPaintDC with BUFFERED_DC_HELPER" )
#define INSTALL_PAINTDC( name, parent ) \
wxBufferedPaintDC name( parent ); \
parent->DoPrepareDC( name ); \
BUFFERED_DC_HELPER help( &name );
#else #else
//#pragma message( "INSTALL_PAINTDC is wxPaintDC" ) //#pragma message( "INSTALL_PAINTDC is wxPaintDC" )
#define INSTALL_PAINTDC(name,parent) \ #define INSTALL_PAINTDC(name,parent) \
...@@ -67,4 +145,11 @@ ...@@ -67,4 +145,11 @@
parent->DoPrepareDC( name ); parent->DoPrepareDC( name );
#endif #endif
// This macro should be used when drawing objects directly without drawing the background.
#define INSTALL_UNBUFFERED_DC( name, parent ) \
wxClientDC name( parent ); \
parent->DoPrepareDC( name );
#endif // __KICAD_DEVICE_CONTEXT_H__ #endif // __KICAD_DEVICE_CONTEXT_H__
...@@ -372,7 +372,17 @@ public: ...@@ -372,7 +372,17 @@ public:
void SetToolbarBgColor( int color_num ); void SetToolbarBgColor( int color_num );
virtual void OnZoom( wxCommandEvent& event ); virtual void OnZoom( wxCommandEvent& event );
void OnGrid( int grid_type ); void OnGrid( int grid_type );
void Recadre_Trace( bool ToMouse );
/**
* Function RedrawScreen
* redraws the entire screen area by updating the scroll bars and mouse pointer in
* order to have the current graphic cursor position at the center of the screen.
* @param aWarpPointer Moves the mouse cursor is to the drawing position ( which
* is usually on grid) if true.
*
* Note: Mac OS ** does not ** allow moving mouse cursor by program.
*/
void RedrawScreen( bool aWarpPointer );
/** Adjust the coordinate to the nearest grid value /** Adjust the coordinate to the nearest grid value
* @param aCoord = coordinate to adjust * @param aCoord = coordinate to adjust
......
...@@ -43,7 +43,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event ) ...@@ -43,7 +43,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
return; return;
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id ) switch( id )
{ {
......
...@@ -237,9 +237,9 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC ) ...@@ -237,9 +237,9 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
{ {
for( i = 0; i < maxi; i++ ) for( i = 0; i < maxi; i++ )
for( j = 0; j < maxi; j++ ) for( j = 0; j < maxi; j++ )
GRSPutPixel( &panel->m_ClipBox, DC, GRPutPixel( &panel->m_ClipBox, DC,
( col * maxi ) + i + DRAW_OFFSET_X, ( col * maxi ) + i + DRAW_OFFSET_X,
( row * maxi ) + j + DRAW_OFFSET_Y, color ); ( row * maxi ) + j + DRAW_OFFSET_Y, color );
} }
} }
......
...@@ -135,7 +135,7 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos ) ...@@ -135,7 +135,7 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos )
if( !DrawPanel->IsPointOnDisplay( aPos ) ) if( !DrawPanel->IsPointOnDisplay( aPos ) )
{ {
screen->m_Curseur = aPos; screen->m_Curseur = aPos;
Recadre_Trace( true ); RedrawScreen( true );
} }
else else
{ {
......
...@@ -550,11 +550,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxP ...@@ -550,11 +550,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxP
typeaff = DisplayOpt.DisplayDrawItems; typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width; width = m_Width;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( width ) < 2 ) if( DC->LogicalToDeviceXRel( width ) < 2 )
#else
if( panel->GetScreen()->Scale( width ) < 2 )
#endif
typeaff = FILAIRE; typeaff = FILAIRE;
switch( typeaff ) switch( typeaff )
......
...@@ -258,11 +258,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx ...@@ -258,11 +258,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
if( m_Flags & FORCE_SKETCH ) if( m_Flags & FORCE_SKETCH )
mode = SKETCH; mode = SKETCH;
#ifdef USE_WX_ZOOM
if( l_piste < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) ) if( l_piste < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) )
#else
if( l_piste < panel->GetScreen()->Unscale( L_MIN_DESSIN ) )
#endif
mode = FILAIRE; mode = FILAIRE;
switch( m_Shape ) switch( m_Shape )
......
...@@ -190,11 +190,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx ...@@ -190,11 +190,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
typeaff = SKETCH; typeaff = SKETCH;
} }
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( m_Width ) < L_MIN_DESSIN ) if( DC->LogicalToDeviceXRel( m_Width ) < L_MIN_DESSIN )
#else
if( screen->Scale( m_Width ) < L_MIN_DESSIN )
#endif
typeaff = FILAIRE; typeaff = FILAIRE;
switch( type_trace ) switch( type_trace )
......
...@@ -118,11 +118,7 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi ...@@ -118,11 +118,7 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi
typeaff = DisplayOpt.DisplayDrawItems; typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width; width = m_Width;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( width ) < 2 ) if( DC->LogicalToDeviceXRel( width ) < 2 )
#else
if( panel->GetScreen()->Scale( width ) < 2 )
#endif
typeaff = FILAIRE; typeaff = FILAIRE;
rayon = m_Size / 4; rayon = m_Size / 4;
......
...@@ -67,11 +67,7 @@ MODULE::~MODULE() ...@@ -67,11 +67,7 @@ MODULE::~MODULE()
void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode ) int dim_ancre, int draw_mode )
{ {
#ifdef USE_WX_ZOOM
int anchor_size = DC->DeviceToLogicalXRel( dim_ancre ); int anchor_size = DC->DeviceToLogicalXRel( dim_ancre );
#else
int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
#endif
GRSetDrawMode( DC, draw_mode ); GRSetDrawMode( DC, draw_mode );
......
...@@ -42,9 +42,7 @@ public: ...@@ -42,9 +42,7 @@ public:
bool m_ShowNCMark; // true to show pad not connected mark bool m_ShowNCMark; // true to show pad not connected mark
bool m_IsPrinting; // true to print, false to display on screen. bool m_IsPrinting; // true to print, false to display on screen.
wxPoint m_Offset; // general draw offset wxPoint m_Offset; // general draw offset
#ifndef USE_WX_ZOOM
double m_Scale; // Draw scaling factor
#endif
PAD_DRAWINFO( ); PAD_DRAWINFO( );
}; };
......
...@@ -37,9 +37,6 @@ PAD_DRAWINFO::PAD_DRAWINFO() ...@@ -37,9 +37,6 @@ PAD_DRAWINFO::PAD_DRAWINFO()
m_Display_netname = true; m_Display_netname = true;
m_ShowPadFilled = true; m_ShowPadFilled = true;
m_ShowNCMark = true; m_ShowNCMark = true;
#ifndef USE_WX_ZOOM
m_Scale = 1.0;
#endif
m_IsPrinting = false; m_IsPrinting = false;
} }
...@@ -319,9 +316,6 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi ...@@ -319,9 +316,6 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDraw_mode, const wxPoi
drawInfo.m_Mask_margin = mask_margin; drawInfo.m_Mask_margin = mask_margin;
drawInfo.m_ShowNCMark = brd->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) ); drawInfo.m_ShowNCMark = brd->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) );
drawInfo.m_IsPrinting = screen->m_IsPrinting; drawInfo.m_IsPrinting = screen->m_IsPrinting;
#ifndef USE_WX_ZOOM
drawInfo.m_Scale = (double) screen->Scale( 1000 ) / 1000;
#endif
SetAlpha( &color, 170 ); SetAlpha( &color, 170 );
/* Get the pad clearance. This has a meaning only for Pcbnew. /* Get the pad clearance. This has a meaning only for Pcbnew.
...@@ -467,11 +461,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -467,11 +461,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
#ifdef USE_WX_ZOOM
if( aDC->LogicalToDeviceXRel( hole ) > 1 ) if( aDC->LogicalToDeviceXRel( hole ) > 1 )
#else
if( aDrawInfo.m_Scale * hole > 1 ) /* draw hole if its size is enough */
#endif
GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0, GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0,
aDrawInfo.m_Color, aDrawInfo.m_HoleColor ); aDrawInfo.m_Color, aDrawInfo.m_HoleColor );
break; break;
...@@ -579,11 +569,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -579,11 +569,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
tsize = min( AreaSize.y, AreaSize.x / numpad_len ); tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#define CHAR_SIZE_MIN 5 #define CHAR_SIZE_MIN 5
#ifdef USE_WX_ZOOM if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
#else
if( aDrawInfo.m_Scale * tsize >= CHAR_SIZE_MIN ) // Not drawable when size too small.
#endif
{ {
// tsize reserve room for marges and segments thickness // tsize reserve room for marges and segments thickness
tsize = (int) ( tsize * 0.8 ); tsize = (int) ( tsize * 0.8 );
...@@ -600,11 +586,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -600,11 +586,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT ); shortname_len = MAX( shortname_len, MIN_CHAR_COUNT );
tsize = min( AreaSize.y, AreaSize.x / shortname_len ); tsize = min( AreaSize.y, AreaSize.x / shortname_len );
#ifdef USE_WX_ZOOM if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
#else
if( aDrawInfo.m_Scale * tsize >= CHAR_SIZE_MIN ) // Not drawable in size too small.
#endif
{ {
tpos = tpos0; tpos = tpos0;
if( aDrawInfo.m_Display_padnum ) if( aDrawInfo.m_Display_padnum )
......
...@@ -354,12 +354,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w ...@@ -354,12 +354,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w
width = m_Thickness; width = m_Thickness;
if( ( frame->m_DisplayModText == FILAIRE ) if( ( frame->m_DisplayModText == FILAIRE )
|| ( DC->LogicalToDeviceXRel( width ) < L_MIN_DESSIN ) )
#ifdef USE_WX_ZOOM
|| ( DC->LogicalToDeviceXRel( width ) < L_MIN_DESSIN ) )
#else
|| ( screen->Scale( width ) < L_MIN_DESSIN ) )
#endif
width = 0; width = 0;
else if( frame->m_DisplayModText == SKETCH ) else if( frame->m_DisplayModText == SKETCH )
width = -width; width = -width;
...@@ -371,11 +366,8 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w ...@@ -371,11 +366,8 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w
{ {
color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
#ifdef USE_WX_ZOOM
int anchor_size = DC->DeviceToLogicalXRel( 2 ); int anchor_size = DC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = screen->Unscale( 2 );
#endif
GRLine( &panel->m_ClipBox, DC, GRLine( &panel->m_ClipBox, DC,
pos.x - anchor_size, pos.y, pos.x - anchor_size, pos.y,
pos.x + anchor_size, pos.y, 0, color ); pos.x + anchor_size, pos.y, 0, color );
......
...@@ -597,11 +597,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& ...@@ -597,11 +597,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
rayon = (int) hypot( (double) ( m_End.x - m_Start.x ), rayon = (int) hypot( (double) ( m_End.x - m_Start.x ),
(double) ( m_End.y - m_Start.y ) ); (double) ( m_End.y - m_Start.y ) );
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN ) if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
#endif
{ {
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
m_Start.y + aOffset.y, rayon, color ); m_Start.y + aOffset.y, rayon, color );
...@@ -609,11 +605,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& ...@@ -609,11 +605,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
else else
{ {
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */ if( DC->LogicalToDeviceXRel( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */
#else
if( panel->GetScreen()->Scale( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */
#endif
{ {
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
m_Start.y + aOffset.y, rayon, color ); m_Start.y + aOffset.y, rayon, color );
...@@ -635,11 +627,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& ...@@ -635,11 +627,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
return; return;
} }
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN ) if( DC->LogicalToDeviceXRel( l_piste ) < L_MIN_DESSIN )
#else
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
#endif
{ {
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
m_Start.y + aOffset.y, m_Start.y + aOffset.y,
...@@ -695,11 +683,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& ...@@ -695,11 +683,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
if( len < THRESHOLD * m_Width ) if( len < THRESHOLD * m_Width )
return; return;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( m_Width ) < 6 ) // no room to display a text inside track if( DC->LogicalToDeviceXRel( m_Width ) < 6 ) // no room to display a text inside track
#else
if( panel->GetScreen()->Scale( m_Width ) < 6 ) // no room to display a text inside track
#endif
return; return;
if( GetNet() == 0 ) if( GetNet() == 0 )
...@@ -722,11 +706,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& ...@@ -722,11 +706,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
if( (m_End.x - m_Start.x) == 0 ) // Vertical segment if( (m_End.x - m_Start.x) == 0 ) // Vertical segment
angle = 900; // angle is in 0.1 degree angle = 900; // angle is in 0.1 degree
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( tsize ) >= 6 ) if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
#else
if( panel->GetScreen()->Scale( tsize ) >= 6 )
#endif
{ {
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) ) if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) )
{ {
...@@ -791,22 +771,14 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint ...@@ -791,22 +771,14 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
rayon = m_Width >> 1; rayon = m_Width >> 1;
// for small via size on screen (rayon < 4 pixels) draw a simplified shape // for small via size on screen (rayon < 4 pixels) draw a simplified shape
#ifdef USE_WX_ZOOM
int radius_in_pixels = DC->LogicalToDeviceXRel( rayon ); int radius_in_pixels = DC->LogicalToDeviceXRel( rayon );
#else
int radius_in_pixels = panel->GetScreen()->Scale( rayon );
#endif
bool fast_draw = false; bool fast_draw = false;
// Vias are drawn as a filled circle or a double circle. The hole will be drawn later // Vias are drawn as a filled circle or a double circle. The hole will be drawn later
int drill_rayon = GetDrillValue() / 2; int drill_rayon = GetDrillValue() / 2;
#ifdef USE_WX_ZOOM
int inner_rayon = rayon - DC->DeviceToLogicalXRel( 2 ); int inner_rayon = rayon - DC->DeviceToLogicalXRel( 2 );
#else
int inner_rayon = rayon - panel->GetScreen()->Unscale( 2 );
#endif
if( radius_in_pixels < 3 ) if( radius_in_pixels < 3 )
{ {
...@@ -852,11 +824,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint ...@@ -852,11 +824,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
else else
GRSetDrawMode( DC, GR_XOR ); GRSetDrawMode( DC, GR_XOR );
#ifdef USE_WX_ZOOM if( DC->LogicalToDeviceXRel( drill_rayon ) > 1 ) // Draw hole if large enough.
if( DC->LogicalToDeviceXRel( drill_rayon ) > 1 ) /* draw hole if its size is enought */
#else
if( screen->Scale( drill_rayon ) > 1 ) /* draw hole if its size is enought */
#endif
GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x, GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
m_Start.y + aOffset.y, drill_rayon, 0, color, color ); m_Start.y + aOffset.y, drill_rayon, 0, color, color );
...@@ -960,11 +928,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint ...@@ -960,11 +928,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
// calculate a good size for the text // calculate a good size for the text
int tsize = m_Width / len; int tsize = m_Width / len;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( tsize ) >= 6 ) if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
#else
if( panel->GetScreen()->Scale( tsize ) >= 6 )
#endif
{ {
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
DrawGraphicText( panel, DC, m_Start, DrawGraphicText( panel, DC, m_Start,
......
...@@ -344,7 +344,8 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -344,7 +344,8 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do. // "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
if( !Drc_On || !g_CurrentTrackSegment if( !Drc_On || !g_CurrentTrackSegment
|| g_CurrentTrackSegment != this->GetCurItem() || g_CurrentTrackSegment != this->GetCurItem()
|| !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment )) || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment,
GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) )
{ {
GetScreen()->m_Curseur = on_grid; GetScreen()->m_Curseur = on_grid;
} }
......
...@@ -121,7 +121,7 @@ void RemoteCommand( const char* cmdline ) ...@@ -121,7 +121,7 @@ void RemoteCommand( const char* cmdline )
} }
if( module ) // if found, center the module on screen, and redraw the screen. if( module ) // if found, center the module on screen, and redraw the screen.
frame->Recadre_Trace( false ); frame->RedrawScreen( false );
} }
......
...@@ -113,7 +113,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -113,7 +113,7 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* aTrack )
container->Remove( aTrack ); container->Remove( aTrack );
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( aTrack->GetBoundingBox() );
SaveCopyInUndoList( aTrack, UR_DELETED ); SaveCopyInUndoList( aTrack, UR_DELETED );
OnModify(); OnModify();
...@@ -163,7 +163,7 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack ) ...@@ -163,7 +163,7 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
GetBoard()->m_Track.Remove( segm ); GetBoard()->m_Track.Remove( segm );
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( segm->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( segm->GetBoundingBox() );
picker.m_PickedItem = segm; picker.m_PickedItem = segm;
picker.m_PickedItemType = segm->Type(); picker.m_PickedItemType = segm->Type();
itemsList.PushItem( picker ); itemsList.PushItem( picker );
...@@ -214,7 +214,7 @@ void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) ...@@ -214,7 +214,7 @@ void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
GetBoard()->m_Track.Remove( tracksegment ); GetBoard()->m_Track.Remove( tracksegment );
// redraw the area where the track was // redraw the area where the track was
DrawPanel->PostDirtyRect( tracksegment->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( tracksegment->GetBoundingBox() );
picker.m_PickedItem = tracksegment; picker.m_PickedItem = tracksegment;
picker.m_PickedItemType = tracksegment->Type(); picker.m_PickedItemType = tracksegment->Type();
itemsList.PushItem( picker ); itemsList.PushItem( picker );
......
...@@ -259,9 +259,9 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, ...@@ -259,9 +259,9 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
int bg_color = g_DrawBgColor; int bg_color = g_DrawBgColor;
g_DrawBgColor = WHITE; g_DrawBgColor = WHITE;
if( aPrint_Frame_Ref ) if( aPrint_Frame_Ref )
m_Parent->TraceWorkSheet( &dc, ActiveScreen, s_Parameters.m_PenDefaultSize ); m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters); m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
......
...@@ -133,26 +133,8 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) ...@@ -133,26 +133,8 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
scale *= 0.7; scale *= 0.7;
dc.SetUserScale( scale, scale ); dc.SetUserScale( scale, scale );
#ifndef USE_WX_ZOOM
drawInfo.m_Scale = scale;
wxPoint org = ActiveScreen->m_DrawOrg;
wxPoint strt = ActiveScreen->m_StartVisu;
int pzoom = ActiveScreen->GetZoom();
ActiveScreen->m_DrawOrg = wxPoint( 0, 0 );
ActiveScreen->m_StartVisu = wxPoint( 0, 0 );
// Actual scaling factor is 10/Zoom
// We need a scale 1 , and therefore zoom = 10
ActiveScreen->SetZoom( 10 );
#endif
m_dummyPad->DrawShape( NULL, &dc, drawInfo ); m_dummyPad->DrawShape( NULL, &dc, drawInfo );
#ifndef USE_WX_ZOOM
ActiveScreen->m_DrawOrg = org;
ActiveScreen->m_StartVisu = strt;
ActiveScreen->SetZoom( pzoom );
#endif
event.Skip(); event.Skip();
} }
...@@ -582,7 +564,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -582,7 +564,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
// redraw the area where the pad was, without pad (delete pad on screen) // redraw the area where the pad was, without pad (delete pad on screen)
m_CurrentPad->m_Flags |= DO_NOT_DRAW; m_CurrentPad->m_Flags |= DO_NOT_DRAW;
m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() );
m_CurrentPad->m_Flags &= ~DO_NOT_DRAW; m_CurrentPad->m_Flags &= ~DO_NOT_DRAW;
// Update values // Update values
...@@ -651,7 +633,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -651,7 +633,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_CurrentPad->DisplayInfo( m_Parent ); m_CurrentPad->DisplayInfo( m_Parent );
// redraw the area where the pad was // redraw the area where the pad was
m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() );
m_Parent->OnModify(); m_Parent->OnModify();
} }
......
...@@ -35,7 +35,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -35,7 +35,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos; wxPoint pos;
int itmp; int itmp;
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
MODULE* module; MODULE* module;
......
...@@ -548,13 +548,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) ...@@ -548,13 +548,10 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
} }
TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, int aLayer, const wxPoint& aRef )
{ {
int net = aTrack->GetNet(); int net = aTrack->GetNet();
int width = aTrack->m_Width; int width = aTrack->m_Width;
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
wxPoint ref = ActiveScreen->RefPos( true );
TRACK* found = NULL; TRACK* found = NULL;
...@@ -565,17 +562,16 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -565,17 +562,16 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
if( track->GetState( BUSY | DELETED ) ) if( track->GetState( BUSY | DELETED ) )
continue; continue;
if( layer != track->GetLayer() ) if( aLayer != track->GetLayer() )
continue; continue;
if( track->GetNet() == net ) if( track->GetNet() == net )
continue; continue;
/* TRACK::HitTest */ /* TRACK::HitTest */
int dist = (width + track->m_Width) / 2 + aTrack->GetClearance( int dist = (width + track->m_Width) / 2 + aTrack->GetClearance( track );
track );
wxPoint pos = ref - track->m_Start; wxPoint pos = aRef - track->m_Start;
wxPoint vec = track->m_End - track->m_Start; wxPoint vec = track->m_End - track->m_Start;
if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) ) if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) )
...@@ -585,8 +581,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -585,8 +581,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
/* prefer intrusions from the side, not the end */ /* prefer intrusions from the side, not the end */
double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y; double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y;
if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y *
vec.y ) if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y * vec.y )
break; break;
} }
} }
...@@ -613,8 +609,9 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ) ...@@ -613,8 +609,9 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
*/ */
static void PushTrack( EDA_DRAW_PANEL* panel ) static void PushTrack( EDA_DRAW_PANEL* panel )
{ {
PCB_SCREEN* screen = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetScreen();
BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard(); BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard();
wxPoint cursor = ActiveScreen->m_Curseur; wxPoint cursor = screen->m_Curseur;
wxPoint cv, vec, n; wxPoint cv, vec, n;
TRACK* track = g_CurrentTrackSegment; TRACK* track = g_CurrentTrackSegment;
TRACK* other; TRACK* other;
...@@ -622,7 +619,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel ) ...@@ -622,7 +619,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel )
int dist; int dist;
double f; double f;
other = LocateIntrusion( pcb->m_Track, track ); other = LocateIntrusion( pcb->m_Track, track, screen->m_Active_Layer, screen->RefPos( true ) );
/* are we currently pointing into a conflicting trace ? */ /* are we currently pointing into a conflicting trace ? */
if( !other ) if( !other )
...@@ -740,7 +737,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase ) ...@@ -740,7 +737,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase )
{ {
if( g_TwoSegmentTrackBuild ) if( g_TwoSegmentTrackBuild )
{ {
g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur; g_CurrentTrackSegment->m_End = screen->m_Curseur;
if( Drc_On ) if( Drc_On )
PushTrack( panel ); PushTrack( panel );
......
...@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text ) ...@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
if( Text->m_Type == TEXT_is_DIVERS ) if( Text->m_Type == TEXT_is_DIVERS )
{ {
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
Text->DeleteStructure(); Text->DeleteStructure();
OnModify(); OnModify();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
...@@ -146,7 +146,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -146,7 +146,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
Text->m_Orient = TextInitialOrientation; Text->m_Orient = TextInitialOrientation;
/* Redraw the text */ /* Redraw the text */
Panel->PostDirtyRect( Text->GetBoundingBox() ); Panel->RefreshDrawingRect( Text->GetBoundingBox() );
// leave it at (0,0) so we can use it Rotate when not moving. // leave it at (0,0) so we can use it Rotate when not moving.
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
...@@ -200,7 +200,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -200,7 +200,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{ {
if( Text != NULL ) if( Text != NULL )
{ {
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
Text->DrawUmbilical( DrawPanel, DC, GR_XOR, -MoveVector ); Text->DrawUmbilical( DrawPanel, DC, GR_XOR, -MoveVector );
/* Update the coordinates for anchor. */ /* Update the coordinates for anchor. */
...@@ -226,7 +226,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -226,7 +226,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
OnModify(); OnModify();
/* Redraw text. */ /* Redraw text. */
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
} }
else else
Text->m_Pos = GetScreen()->m_Curseur; Text->m_Pos = GetScreen()->m_Curseur;
......
...@@ -199,7 +199,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -199,7 +199,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( aDraw ) if( aDraw )
{ {
Module->m_Flags |= DO_NOT_DRAW; Module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
Module->m_Flags &= ~DO_NOT_DRAW; Module->m_Flags &= ~DO_NOT_DRAW;
} }
...@@ -273,7 +273,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -273,7 +273,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
if( aDraw ) if( aDraw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
} }
OnModify(); OnModify();
......
...@@ -164,7 +164,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -164,7 +164,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos; wxPoint pos;
bool redraw = false; bool redraw = false;
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
......
...@@ -138,7 +138,7 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ), ...@@ -138,7 +138,7 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
Place_Ancre( module ); // set the new relatives internal Place_Ancre( module ); // set the new relatives internal
// coordinates of items // coordinates of items
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
Recadre_Trace( TRUE ); RedrawScreen( TRUE );
// Replace the module in position 0, to recalculate absolutes // Replace the module in position 0, to recalculate absolutes
// coordinates of items // coordinates of items
......
...@@ -104,7 +104,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) ...@@ -104,7 +104,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
{ {
int tmp = module->m_Flags; int tmp = module->m_Flags;
module->m_Flags |= DO_NOT_DRAW; module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( module->GetBoundingBox() );
module->m_Flags = tmp; module->m_Flags = tmp;
} }
...@@ -328,7 +328,7 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -328,7 +328,7 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
{ {
int tmp = Module->m_Flags; int tmp = Module->m_Flags;
Module->m_Flags |= DO_NOT_DRAW; Module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
Module->m_Flags = tmp; Module->m_Flags = tmp;
} }
...@@ -482,7 +482,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module, ...@@ -482,7 +482,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
{ {
int tmp = module->m_Flags; int tmp = module->m_Flags;
module->m_Flags |= DO_NOT_DRAW; module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( module->GetBoundingBox() );
module->m_Flags = tmp; module->m_Flags = tmp;
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
......
...@@ -128,7 +128,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -128,7 +128,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( aDraw ) if( aDraw )
{ {
aPad->m_Flags |= DO_NOT_DRAW; aPad->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( aPad->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( aPad->GetBoundingBox() );
aPad->m_Flags &= ~DO_NOT_DRAW; aPad->m_Flags &= ~DO_NOT_DRAW;
} }
...@@ -166,7 +166,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -166,7 +166,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
aPad->ComputeShapeMaxRadius(); aPad->ComputeShapeMaxRadius();
if( aDraw ) if( aDraw )
DrawPanel->PostDirtyRect( aPad->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( aPad->GetBoundingBox() );
( (MODULE*) aPad->GetParent() )->m_LastEdit_Time = time( NULL ); ( (MODULE*) aPad->GetParent() )->m_LastEdit_Time = time( NULL );
} }
...@@ -220,7 +220,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw ) ...@@ -220,7 +220,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Pad->DisplayInfo( this ); Pad->DisplayInfo( this );
if( draw ) if( draw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
} }
...@@ -254,7 +254,7 @@ void WinEDA_BasePcbFrame::DeletePad( D_PAD* aPad, bool aQuery ) ...@@ -254,7 +254,7 @@ void WinEDA_BasePcbFrame::DeletePad( D_PAD* aPad, bool aQuery )
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
aPad->DeleteStructure(); aPad->DeleteStructure();
DrawPanel->PostDirtyRect( Module->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
OnModify(); OnModify();
......
...@@ -21,7 +21,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event ) ...@@ -21,7 +21,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event )
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
wxGetMousePosition( &pos.x, &pos.y ); wxGetMousePosition( &pos.x, &pos.y );
......
...@@ -261,11 +261,9 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -261,11 +261,9 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
* the old draw area in the new draw area, because the draw origin has not moved * the old draw area in the new draw area, because the draw origin has not moved
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area * (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
* is the y coordinate values from - PlotAreaSize.y to 0 */ * is the y coordinate values from - PlotAreaSize.y to 0 */
#ifdef USE_WX_ZOOM
int y_dc_offset = PlotAreaSizeInPixels.y; int y_dc_offset = PlotAreaSizeInPixels.y;
y_dc_offset = (int) ( ( double ) y_dc_offset * userscale ); y_dc_offset = (int) ( ( double ) y_dc_offset * userscale );
dc->SetDeviceOrigin( 0, y_dc_offset ); dc->SetDeviceOrigin( 0, y_dc_offset );
#endif
int ysize = (int) ( PlotAreaSizeInPixels.y / scaley ); int ysize = (int) ( PlotAreaSizeInPixels.y / scaley );
DrawOffset.y += ysize; DrawOffset.y += ysize;
...@@ -277,13 +275,11 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -277,13 +275,11 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
* to the middle of the page. * to the middle of the page.
*/ */
wxPoint pcb_centre = brd_BBox.Centre(); wxPoint pcb_centre = brd_BBox.Centre();
if( userscale <= 1.0 ) if( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize / 2); DrawOffset.y += pcb_centre.y - (ysize / 2);
#ifdef USE_WX_ZOOM
dc->SetLogicalOrigin( ActiveScreen->m_DrawOrg.x, ActiveScreen->m_DrawOrg.y ); dc->SetLogicalOrigin( ActiveScreen->m_DrawOrg.x, ActiveScreen->m_DrawOrg.y );
#else
ActiveScreen->m_DrawOrg = DrawOffset;
#endif
panel->m_ClipBox.SetOrigin( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ) ); panel->m_ClipBox.SetOrigin( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ) );
} }
......
...@@ -211,7 +211,7 @@ void Montre_Position_Empreinte( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase ); ...@@ -211,7 +211,7 @@ void Montre_Position_Empreinte( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
/* EDITRACK.C : */ /* EDITRACK.C : */
/****************/ /****************/
TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack ); TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, int aLayer, const wxPoint& aRef );
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase ); void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
......
...@@ -78,7 +78,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event ) ...@@ -78,7 +78,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
if( found ) if( found )
{ {
INSTALL_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
if( g_HighLight_Status ) if( g_HighLight_Status )
High_Light( &dc ); High_Light( &dc );
......
...@@ -329,7 +329,7 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_contain ...@@ -329,7 +329,7 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_contain
if( zone_container->m_Poly->GetNumCorners() <= 3 ) if( zone_container->m_Poly->GetNumCorners() <= 3 )
{ {
DrawPanel->PostDirtyRect( zone_container->GetBoundingBox() ); DrawPanel->RefreshDrawingRect( zone_container->GetBoundingBox() );
if( DC ) if( DC )
{ // Remove the full zone because this is no more an area { // Remove the full zone because this is no more an area
Delete_Zone_Fill( NULL, zone_container->m_TimeStamp ); Delete_Zone_Fill( NULL, zone_container->m_TimeStamp );
...@@ -864,7 +864,7 @@ void WinEDA_PcbFrame::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_contai ...@@ -864,7 +864,7 @@ void WinEDA_PcbFrame::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_contai
zone_container->m_Poly->RemoveContour( ncont ); zone_container->m_Poly->RemoveContour( ncont );
} }
DrawPanel->PostDirtyRect( dirty ); DrawPanel->RefreshDrawingRect( dirty );
OnModify(); OnModify();
} }
......
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