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
#for those who bored with uppercase
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
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")
......@@ -61,18 +59,12 @@ if(KICAD_KEEPCASE)
add_definitions(-DKICAD_KEEPCASE)
endif(KICAD_KEEPCASE)
if(USE_WX_ZOOM)
add_definitions(-DUSE_WX_ZOOM)
endif(USE_WX_ZOOM)
if(USE_WX_OVERLAY OR APPLE)
add_definitions(-DUSE_WX_OVERLAY)
endif(USE_WX_OVERLAY OR APPLE)
if(USE_WX_GRAPHICS_CONTEXT)
set( USE_WX_ZOOM ON )
add_definitions(-DUSE_WX_ZOOM)
add_definitions(-DUSE_WX_GRAPHICS_CONTEXT)
endif(USE_WX_GRAPHICS_CONTEXT)
......
......@@ -49,9 +49,6 @@
#define strnicmp _strnicmp
#endif
/* Warning!!! Using wxDC for zooming is experimental. */
#cmakedefine USE_WX_ZOOM 1
/* Warning!!! Using wxGraphicContext for rendering is experimental. */
#cmakedefine USE_WX_GRAPHICS_CONTEXT 1
......
......@@ -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
* calculates the .m_Zoom member to have a given scaling factor
......@@ -131,113 +114,15 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
// Limit zoom to max and min allowed values:
if (zoom < m_ZoomList[0])
zoom = m_ZoomList[0];
int idxmax = m_ZoomList.GetCount() - 1;
if (zoom > m_ZoomList[idxmax])
zoom = m_ZoomList[idxmax];
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 )
{
if( !m_ZoomList.IsEmpty() )
......
......@@ -399,11 +399,7 @@ void EDA_TextStruct::DrawOneLineOfText( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
if( aAnchor_color != UNSPECIFIED_COLOR )
{
#if USE_WX_ZOOM
int anchor_size = aDC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = aPanel->GetScreen()->Unscale( 2 );
#endif
aAnchor_color = (EDA_Colors) ( aAnchor_color & MASKCOLOR );
......
......@@ -96,16 +96,15 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
}
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor )
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor )
{
int w = aPanel->GetScreen()->Scale( GetWidth() );
int h = aPanel->GetScreen()->Scale( GetHeight() );
int w = GetWidth();
int h = GetHeight();
GRSetDrawMode( aDC, aDrawMode );
if( w == 0 || h == 0 )
GRLine( &aPanel->m_ClipBox, aDC, GetX() + aOffset.x, GetY() + aOffset.y,
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
......
......@@ -289,7 +289,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
return;
GetBaseScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
GetBaseScreen()->SetZoom( selectedZoom );
Recadre_Trace( false );
RedrawScreen( false );
}
}
......
......@@ -12,7 +12,6 @@
#include "class_base_screen.h"
#include "wxstruct.h"
#include <wx/wupdlock.h>
#include "kicad_device_context.h"
#define CURSOR_SIZE 12 // Cursor size in pixels
......@@ -21,12 +20,13 @@
/* Definitions for enabling and disabling debugging features in drawpanel.cpp.
* Please don't forget to turn these off before making any SvN commits.
* Please don't forget to turn these off before making any commits to Launchpad.
*/
#define DEBUG_SHOW_CLIP_RECT 0 // Set to 1 to draw clipping rectangle.
#define DEBUG_DUMP_CLIP_COORDS 0 // Set to 1 to dump clipping rectangle coordinates.
#define DEBUG_DUMP_SCROLL_SETTINGS 0 // Set to 1 to dump scroll settings.
#define KICAD_TRACE_COORDS wxT( "kicad_dump_coords" )
/* Used to inhibit a response to a mouse left button release, after a
......@@ -45,12 +45,13 @@ BEGIN_EVENT_TABLE( EDA_DRAW_PANEL, wxScrolledWindow )
EVT_CHAR( EDA_DRAW_PANEL::OnKeyEvent )
EVT_CHAR_HOOK( EDA_DRAW_PANEL::OnKeyEvent )
EVT_PAINT( EDA_DRAW_PANEL::OnPaint )
EVT_SIZE( EDA_DRAW_PANEL::OnSize )
EVT_ERASE_BACKGROUND( EDA_DRAW_PANEL::OnEraseBackground )
EVT_SCROLLWIN( EDA_DRAW_PANEL::OnScroll )
EVT_ACTIVATE( EDA_DRAW_PANEL::OnActivate )
EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, EDA_DRAW_PANEL::OnPan )
END_EVENT_TABLE()
/***********************************************************************/
/* EDA_DRAW_PANEL base functions (EDA_DRAW_PANEL is the main panel)*/
/***********************************************************************/
......@@ -58,20 +59,22 @@ END_EVENT_TABLE()
EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
const wxPoint& pos, const wxSize& size ) :
wxScrolledWindow( parent, id, pos, size,
wxBORDER | wxNO_FULL_REPAINT_ON_RESIZE )
wxBORDER | wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE )
{
m_Parent = parent;
wxASSERT( m_Parent );
m_scrollIncrementX = MIN( size.x / 8, 10 );
m_scrollIncrementY = MIN( size.y / 8, 10 );
SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue ) );
#if defined KICAD_USE_BUFFERED_DC || defined KICAD_USE_BUFFERED_PAINTDC
#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
#endif
EnableScrolling( TRUE, TRUE );
m_ClipBox.SetSize( size );
m_ClipBox.SetX( 0 );
m_ClipBox.SetY( 0 );
......@@ -85,14 +88,15 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
ForceCloseManageCurseur = NULL;
if( wxGetApp().m_EDA_Config )
wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), &m_AutoPAN_Enable,
true );
wxGetApp().m_EDA_Config->Read( wxT( "AutoPAN" ), &m_AutoPAN_Enable, true );
m_AutoPAN_Request = false;
m_Block_Enable = false;
m_PanelDefaultCursor = m_PanelCursor = wxCURSOR_ARROW;
m_CursorLevel = 0;
m_PrintIsMirrored = false;
wxLog::AddTraceMask( KICAD_TRACE_COORDS );
}
......@@ -119,7 +123,7 @@ void EDA_DRAW_PANEL::DrawCursor( wxDC* aDC, int aColor )
return;
#ifdef __WXMAC__
SetCursor(*wxCROSS_CURSOR);
SetCursor( *wxCROSS_CURSOR );
return;
#endif
......@@ -129,30 +133,17 @@ void EDA_DRAW_PANEL::DrawCursor( wxDC* aDC, int aColor )
if( m_Parent->m_CursorShape == 1 ) /* Draws a crosshair. */
{
#ifdef USE_WX_ZOOM
wxSize clientSize = GetClientSize();
wxPoint lineStart = wxPoint( Cursor.x, aDC->DeviceToLogicalY( 0 ) );
wxPoint lineEnd = wxPoint( Cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // Y azis
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // Y axis
lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), Cursor.y );
lineEnd = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), Cursor.y );
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // X azis
#else
int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
GRLine( &m_ClipBox, aDC, Cursor.x - dx, Cursor.y,
Cursor.x + dx, Cursor.y, 0, aColor ); // Y axis
GRLine( &m_ClipBox, aDC, Cursor.x, Cursor.y - dx,
Cursor.x, Cursor.y + dy, 0, aColor ); // X axis
#endif
GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor ); // X axis
}
else
{
#ifdef USE_WX_ZOOM
int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );
#else
int len = GetScreen()->Unscale( CURSOR_SIZE );
#endif
GRLine( &m_ClipBox, aDC, Cursor.x - len, Cursor.y,
Cursor.x + len, Cursor.y, 0, aColor );
......@@ -232,93 +223,36 @@ bool EDA_DRAW_PANEL::IsPointOnDisplay( wxPoint ref_pos )
wxPoint pos;
EDA_Rect display_rect;
INSTALL_DC( dc, this ); // Refresh the boundary box.
INSTALL_UNBUFFERED_DC( dc, this ); // Refresh the boundary box.
SetClipBox( dc );
display_rect = m_ClipBox;
// Slightly decreased the size of the useful screen area to avoid drawing
// limits.
// Slightly decreased the size of the useful screen area to avoid drawing limits.
#define PIXEL_MARGIN 8
display_rect.Inflate( -PIXEL_MARGIN );
#ifndef USE_WX_ZOOM
// Convert physical coordinates.
pos = CalcUnscrolledPosition( display_rect.GetPosition() );
GetScreen()->Unscale( pos );
pos += GetScreen()->m_DrawOrg;
display_rect.m_Pos = pos;
GetScreen()->Unscale( display_rect.m_Size );
#endif
return display_rect.Contains( ref_pos );
}
void EDA_DRAW_PANEL::PostDirtyRect( EDA_Rect aRect )
void EDA_DRAW_PANEL::RefreshDrawingRect( const EDA_Rect& aRect, bool aEraseBackground )
{
// D( printf( "1) PostDirtyRect( x=%d, y=%d, width=%d, height=%d)\n", aRect.m_Pos.x, aRect.m_Pos.y, aRect.m_Size.x, aRect.m_Size.y ); )
// Convert the rect coordinates and size to pixels (make a draw clip box):
ConvertPcbUnitsToPixelsUnits( &aRect );
INSTALL_UNBUFFERED_DC( dc, this );
// Ensure the rectangle is large enough after truncations.
// The pcb units have finer granularity than the pixels, so it can happen
// that the rectangle is not large enough for the erase portion.
wxRect rect = aRect;
aRect.m_Size.x += 4; // += 1 is not enough!
aRect.m_Size.y += 4;
rect.x = dc.LogicalToDeviceX( rect.x );
rect.y = dc.LogicalToDeviceY( rect.y );
rect.width = dc.LogicalToDeviceXRel( rect.width );
rect.height = dc.LogicalToDeviceYRel( rect.height );
// D( printf( "2) PostDirtyRect( x=%d, y=%d, width=%d, height=%d)\n", aRect.m_Pos.x, aRect.m_Pos.y, aRect.m_Size.x, aRect.m_Size.y ); )
wxLogTrace( KICAD_TRACE_COORDS,
wxT( "Refresh area: drawing (%d, %d, %d, %d), device (%d, %d, %d, %d)" ),
aRect.GetX(), aRect.GetY(), aRect.GetWidth(), aRect.GetHeight(),
rect.x, rect.y, rect.width, rect.height );
// pass wxRect() via EDA_Rect::operator wxRect() overload
RefreshRect( aRect, TRUE );
}
/**
* Scale and offset a rectangle in drawing units to device units.
*
* This is the equivalent of wxDC::LogicalToDevice.
*
* @param aRect - Rectangle to scale.
*/
void EDA_DRAW_PANEL::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
{
// Calculate the draw area origin in internal units:
wxPoint pos = aRect->GetPosition();
ConvertPcbUnitsToPixelsUnits( &pos );
aRect->SetOrigin( pos ); // rect origin in pixel units
double scale = GetScreen()->GetScalingFactor();
aRect->m_Size.x = wxRound( (double) aRect->m_Size.x * scale );
aRect->m_Size.y = wxRound( (double) aRect->m_Size.y * scale );
}
void EDA_DRAW_PANEL::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
{
// Calculate the draw area origin in internal units:
wxPoint drwOrig;
int x_axis_scale, y_axis_scale;
// Origin in scroll units;
GetViewStart( &drwOrig.x, &drwOrig.y );
GetScrollPixelsPerUnit( &x_axis_scale, &y_axis_scale );
// Origin in pixels units
drwOrig.x *= x_axis_scale;
drwOrig.y *= y_axis_scale;
double x, y;
double scalar = GetScreen()->GetScalingFactor();
x = (double) aPosition->x - ( ( (double) drwOrig.x / scalar )
+ (double) GetScreen()->m_DrawOrg.x );
y = (double) aPosition->y - ( ( (double) drwOrig.y / scalar )
+ (double) GetScreen()->m_DrawOrg.y );
aPosition->x = wxRound( x * scalar );
aPosition->y = wxRound( y * scalar );
RefreshRect( rect, aEraseBackground );
}
......@@ -382,14 +316,12 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
CalcScrolledPosition( Mouse.x, Mouse.y, &screenPos.x, &screenPos.y );
/* Scroll if the requested mouse position cursor is outside the drawing
* area. */
// Scroll if the requested mouse position cursor is outside the drawing area.
if( !clientRect.Contains( screenPos ) )
{
GetViewStart( &x, &y );
GetScrollPixelsPerUnit( &xPpu, &yPpu );
CalcUnscrolledPosition( screenPos.x, screenPos.y,
&drawingPos.x, &drawingPos.y );
CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y );
wxLogDebug( wxT( "MouseTo() initial screen position(%d, %d) " ) \
wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ),
......@@ -406,11 +338,10 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
x -= m_scrollIncrementX * xPpu;
Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y,
&screenPos.x, &screenPos.y );
CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y );
wxLogDebug( wxT( "MouseTo() scrolled screen position(%d, %d) " ) \
wxT( "view(%d, %d)" ), screenPos.x, screenPos.y, x, y );
wxLogDebug( wxT( "MouseTo() scrolled screen position(%d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, x, y );
}
WarpPointer( screenPos.x, screenPos.y );
......@@ -430,6 +361,7 @@ void EDA_DRAW_PANEL::OnActivate( wxActivateEvent& event )
event.Skip();
}
void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
{
int id = event.GetEventType();
......@@ -455,12 +387,14 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
if( dir == wxHORIZONTAL )
{
x -= m_scrollIncrementX;
if( x < 0 )
x = 0;
}
else
{
y -= m_scrollIncrementY;
if( y < 0 )
y = 0;
}
......@@ -476,6 +410,7 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
else
{
y += m_scrollIncrementY;
if( y > maxY )
y = maxY;
}
......@@ -502,70 +437,52 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
event.Skip();
}
void EDA_DRAW_PANEL::OnSize( wxSizeEvent& event )
{
if( IsShown() )
{
INSTALL_DC( dc, this ); // Update boundary box.
}
event.Skip();
}
/**
* Function SetBoundaryBox
* Set the clip box to the current displayed rectangle dimensions.
*
* When using wxDC for scaling, the clip box coordinates are in drawing (logical)
* units. In other words, the area of the drawing that will be displayed on the
* screen. When using Kicad's scaling, the clip box coordinates are in screen
* (device) units according to the current scroll position.
*
* @param dc - The device context use for drawing with the correct scale and
* offsets already configured. See DoPrepareDC().
*/
void EDA_DRAW_PANEL::SetBoundaryBox( wxDC* dc )
void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect )
{
wxASSERT( dc != NULL );
wxRect clipBox;
// Use the entire visible device area if no clip area was defined.
if( aRect == NULL )
{
BASE_SCREEN* Screen = GetScreen();
BASE_SCREEN* Screen = GetScreen();;
if( !Screen )
return;
if( !Screen )
return;
Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
clipBox.SetSize( GetClientSize() );
Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
m_ClipBox.SetSize( GetClientSize() );
int scrollX, scrollY;
int scrollX, scrollY;
double scalar = Screen->GetScalingFactor();
scrollX = wxRound( Screen->GetGridSize().x * scalar );
scrollY = wxRound( Screen->GetGridSize().y * scalar );
#ifdef USE_WX_ZOOM
double scalar = Screen->GetScalingFactor();
scrollX = wxRound( Screen->GetGridSize().x * scalar );
scrollY = wxRound( Screen->GetGridSize().y * scalar );
#else
scrollX = wxRound( Screen->Scale( Screen->GetGridSize().x ) );
scrollY = wxRound( Screen->Scale( Screen->GetGridSize().y ) );
#endif
m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
}
else
{
clipBox = *aRect;
}
m_scrollIncrementX = MAX( GetClientSize().x / 8, scrollX );
m_scrollIncrementY = MAX( GetClientSize().y / 8, scrollY );
// Pad clip box in device units.
clipBox.Inflate( CLIP_BOX_PADDING );
// Convert from device units to drawing units.
m_ClipBox.m_Pos = wxPoint( aDC.DeviceToLogicalX( clipBox.x ),
aDC.DeviceToLogicalY( clipBox.y ) );
m_ClipBox.m_Size = wxSize( aDC.DeviceToLogicalXRel( clipBox.width ),
aDC.DeviceToLogicalYRel( clipBox.height ) );
#ifdef USE_WX_ZOOM
/* Using wxDC scaling requires clipping in drawing (logical) units. */
m_ClipBox.SetOrigin( CalcUnscrolledPosition( wxPoint( 0, 0 ) ) );
m_ClipBox.Inflate( CLIP_BOX_PADDING );
m_ClipBox.m_Pos.x = wxRound( (double) m_ClipBox.m_Pos.x / scalar );
m_ClipBox.m_Pos.y = wxRound( (double) m_ClipBox.m_Pos.y / scalar );
m_ClipBox.m_Pos += Screen->m_DrawOrg;
m_ClipBox.m_Size.x = wxRound( (double) m_ClipBox.m_Size.x / scalar );
m_ClipBox.m_Size.y = wxRound( (double) m_ClipBox.m_Size.y / scalar );
#if DEBUG_DUMP_CLIP_COORDS
wxLogDebug( wxT( "Device clip box=(%d, %d, %d, %d), Logical clip box=(%d, %d, %d, %d)" ),
clipBox.x, clipBox.y, clipBox.width, clipBox.height,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#endif
Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
}
......@@ -573,38 +490,35 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
{
GRSetDrawMode( DC, GR_COPY );
GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
0, g_DrawBgColor, g_DrawBgColor );
/* Set to one (1) to draw bounding box validate bounding box calculation. */
#if DEBUG_SHOW_CLIP_RECT
EDA_Rect bBox = m_ClipBox;
bBox.Inflate( -DC->DeviceToLogicalXRel( 1 ) );
GRRect( NULL, DC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
}
void EDA_DRAW_PANEL::DoPrepareDC(wxDC& dc)
void EDA_DRAW_PANEL::DoPrepareDC( wxDC& dc )
{
#ifdef USE_WX_ZOOM
wxScrolledWindow::DoPrepareDC( dc );
if( GetScreen() != NULL )
{
double scale = GetScreen()->GetScalingFactor();
dc.SetUserScale( scale, scale );
wxPoint pt = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
dc.SetDeviceOrigin( -pt.x, -pt.y );
pt = GetScreen()->m_DrawOrg;
wxPoint pt = GetScreen()->m_DrawOrg;
dc.SetLogicalOrigin( pt.x, pt.y );
}
#endif
SetClipBox( dc ); // Reset the clip box to the entire screen.
GRResetPenAndBrush( &dc );
dc.SetBackgroundMode( wxTRANSPARENT );
SetBoundaryBox( &dc );
}
......@@ -618,67 +532,10 @@ void EDA_DRAW_PANEL::OnPaint( wxPaintEvent& event )
INSTALL_PAINTDC( paintDC, this );
/* wxAutoBufferedPaintDC does not work correctly by setting the user scale and
* logcial offset. The bitmap coordinates and scaling are not effected by the
* code below. It appears that the wxBufferPaintDC needs to be created with the
* wxBUFFER_VIRTUAL_AREA set and the wirtual method wxWindow::PrepareDC() needs
* to be overridden to set up the buffered paint DC properly. The bitmap grid
* draw code ( see DrawGrid() below ) will have to be fixed before this can be
* implemented.
*/
EDA_Rect tmp = m_ClipBox;
// Get the union of all rectangles in the update region.
wxRect PaintClipBox = GetUpdateRegion().GetBox();
#if DEBUG_DUMP_CLIP_COORDS
wxLogDebug( wxT( "1) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
PaintClipBox.x, PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#endif
#if defined( USE_WX_ZOOM )
/* When using wxDC scaling the clipping region coordinates are in drawing
* (logical) units.
*/
double scalar = GetScreen()->GetScalingFactor();
m_ClipBox.m_Pos = CalcUnscrolledPosition( PaintClipBox.GetPosition() );
m_ClipBox.m_Size = PaintClipBox.GetSize();
m_ClipBox.Inflate( CLIP_BOX_PADDING );
m_ClipBox.m_Pos.x = wxRound( (double) m_ClipBox.m_Pos.x / scalar );
m_ClipBox.m_Pos.y = wxRound( (double) m_ClipBox.m_Pos.y / scalar );
m_ClipBox.m_Pos += GetScreen()->m_DrawOrg;
m_ClipBox.m_Size.x = wxRound( (double) m_ClipBox.m_Size.x / scalar );
m_ClipBox.m_Size.y = wxRound( (double) m_ClipBox.m_Size.y / scalar );
PaintClipBox = m_ClipBox;
#else
/* When using Kicad's scaling the clipping region coordinates are in screen
* (device) units.
*/
m_ClipBox.SetX( PaintClipBox.GetX() );
m_ClipBox.SetY( PaintClipBox.GetY() );
m_ClipBox.SetWidth( PaintClipBox.GetWidth() );
m_ClipBox.SetHeight( PaintClipBox.GetHeight() );
// Be sure the drawpanel clipbox is bigger than the region to repair:
m_ClipBox.Inflate( 1 ); // Give it one pixel more in each direction
#endif
#if DEBUG_DUMP_CLIP_COORDS
wxLogDebug( wxT( "2) PaintClipBox=(%d, %d, %d, %d), m_ClipBox=(%d, %d, %d, %d)" ),
PaintClipBox.x, PaintClipBox.y, PaintClipBox.width, PaintClipBox.height,
m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y, m_ClipBox.m_Size.x, m_ClipBox.m_Size.y );
#endif
// call ~wxDCClipper() before ~wxPaintDC()
{
wxDCClipper dcclip( paintDC, PaintClipBox );
ReDraw( &paintDC, m_DisableEraseBG ? false : true );
}
m_ClipBox = tmp;
event.Skip();
wxRect region = GetUpdateRegion().GetBox();
SetClipBox( paintDC, &region );
wxDCClipper dcclip( paintDC, m_ClipBox );
ReDraw( &paintDC, m_DisableEraseBG ? false : true );
}
......@@ -706,10 +563,6 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
if( erasebg )
EraseScreen( DC );
SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
ColorRefs[g_DrawBgColor].m_Green,
ColorRefs[g_DrawBgColor].m_Blue ) );
GRResetPenAndBrush( DC );
DC->SetBackground( *wxBLACK_BRUSH );
......@@ -767,152 +620,80 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* DC )
{
#define MIN_GRID_SIZE 10 // min grid size in pixels to allow drawing
BASE_SCREEN* screen = GetScreen();
int ii, jj, xg, yg;
wxRealPoint screen_grid_size;
wxSize size;
wxRealPoint gridSize;
wxSize screenSize;
wxPoint org;
wxRealPoint dgrid;
wxRealPoint screenGridSize;
/* The grid must be visible. this is possible only is grid value
* and zoom value are sufficient
*/
screen_grid_size = screen->GetGridSize();
org = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
screen->m_StartVisu = org;
size = GetClientSize();
gridSize = screen->GetGridSize();
screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
screenSize = GetClientSize();
#ifdef USE_WX_ZOOM
dgrid.x = DC->LogicalToDeviceXRel( wxRound( screen_grid_size.x ) );
dgrid.y = DC->LogicalToDeviceXRel( wxRound( screen_grid_size.y ) );
screenGridSize.x = DC->LogicalToDeviceXRel( wxRound( gridSize.x ) );
screenGridSize.y = DC->LogicalToDeviceXRel( wxRound( gridSize.y ) );
org = m_ClipBox.m_Pos;
size = m_ClipBox.m_Size;
#else
dgrid = screen_grid_size;
screen->Scale( dgrid ); // dgrid = grid size in pixels
screen->Unscale( size );
screen->Unscale( org );
org += screen->m_DrawOrg;
#endif
// if the grid size is small ( < MIN_GRID_SIZE pixels ) do not display all points
bool double_size = false;
if( dgrid.x < MIN_GRID_SIZE )
if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
{
double_size = true;
dgrid.x *= 2;
screenGridSize.x *= 2.0;
screenGridSize.y *= 2.0;
gridSize.x *= 2.0;
gridSize.y *= 2.0;
}
if( dgrid.x < MIN_GRID_SIZE )
return; // The X grid is too small: do not show it
if( dgrid.y < MIN_GRID_SIZE )
{
double_size = true;
dgrid.y *= 2;
}
if( dgrid.y < MIN_GRID_SIZE )
return; // The Y grid is too small: do not show it
if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
return;
m_Parent->PutOnGrid( &org, &gridSize );
m_Parent->PutOnGrid( &org );
#if ( defined( __WXMAC__ ) || defined( __WXGTK__ ) || 1 )
// Use a pixel based draw to display grid. There are a lot of calls, so the cost is high
// and grid is slowly drawn on some platforms. Please note that this should always be
// enabled until the bitmap based solution below is fixed.
GRSetColorPen( DC, m_Parent->GetGridColor() );
int xpos, ypos;
/* When we use an double_size grid, we must align grid ord on double grid
*/
int increment = double_size ? 2 : 1;
if( double_size )
{
wxRealPoint dblgrid = screen_grid_size + screen_grid_size;
m_Parent->PutOnGrid( &org, &dblgrid );
}
int xpos;
double right = ( double ) m_ClipBox.GetRight();
double bottom = ( double ) m_ClipBox.GetBottom();
// Draw grid: the best algorithm depend on the platform.
// under macOSX, the first method is better
// under window, the second method is better
// Under linux, to be tested (could be depend on linux versions
// so perhaps could be necessary to set this option at run time.
/* The bitmap grid drawing code below cannot be used when wxDC scaling is used
* as it does not scale the grid bitmap properly. This needs to be fixed.
*/
#if defined( __WXMAC__ ) && !defined( USE_WX_ZOOM )
// Use a pixel based draw to display grid
// When is not used USE_WX_ZOOM
for( ii = 0; ; ii += increment )
for( double x = (double) org.x; x <= right; x += gridSize.x )
{
xg = wxRound( ii * screen_grid_size.x );
if( xg > size.x )
break;
xpos = org.x + xg;
xpos = GRMapX( xpos );
for( jj = 0; ; jj += increment )
{
yg = wxRound( jj * screen_grid_size.y );
if( yg > size.y )
break;
ypos = org.y + yg;
DC->DrawPoint( xpos, GRMapY( ypos ) );
}
}
#endif
xpos = wxRound( x );
#if defined( USE_WX_ZOOM )
// Use a pixel based draw to display grid
// There is a lot of calls, so the cost is hight
// and grid is slowly drawn on some platforms
for( ii = 0; ; ii += increment )
{
xg = wxRound( ii * screen_grid_size.x );
if( xg > size.x )
break;
xpos = org.x + xg;
xpos = GRMapX( xpos );
if( xpos < m_ClipBox.GetOrigin().x ) // column not in active screen area.
continue;
if( xpos > m_ClipBox.GetEnd().x ) // end of active area reached.
break;
for( jj = 0; ; jj += increment )
for( double y = (double) org.y; y <= bottom; y += gridSize.y )
{
yg = wxRound( jj * screen_grid_size.y );
if( yg > size.y )
break;
ypos = org.y + yg;
if( ypos < m_ClipBox.GetOrigin().y ) // column not in active screen area.
continue;
if( ypos > m_ClipBox.GetEnd().y ) // end of active area reached.
break;
DC->DrawPoint( xpos, GRMapY( ypos ) );
DC->DrawPoint( xpos, wxRound( y ) );
}
}
#else
/* Currently on test: Use a fast way to draw the grid
* But this is fast only if the Blit function is fast. Not true on all platforms
* a grid column is drawn; and then copied to others grid columns
* this is possible because the grid is drawn only after clearing the screen.
/* Currently under development: use a bitmap to draw the grid. This is fast only if the
* Blit function is fast. Not true on all platforms.
*
* A first grid column is drawn in a temporary bitmap,
* and after is duplicated using the Blit function
* (copy from a screen area to an other screen area)
* A single grid column is drawn to a bitmap and then copied to each column. This is
* possible because the grid is drawn only after clearing the screen.
*
* A first grid column is drawn in a temporary bitmap, and after is duplicated using
* the Blit function (copy from a screen area to an other screen area).
*/
wxSize screenSize = GetClientSize();
wxMemoryDC tmpDC;
wxBitmap tmpBM( 1, screenSize.y );
tmpDC.SelectObject( tmpBM );
wxBitmap tmpBM( 1, m_ClipBox.GetHeight() );
tmpDC.SelectObjectAsSource( tmpBM );
GRSetColorPen( &tmpDC, g_DrawBgColor );
tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background
tmpDC.DrawLine( 0, 0, 0, m_ClipBox.GetHeight() - 1 ); // init background
GRSetColorPen( &tmpDC, m_Parent->GetGridColor() );
for( jj = 0; ; jj += increment ) // draw grid points
double bottom = ( double ) m_ClipBox.GetBottom();
for( double y = (double) org.y; y <= bottom; y += gridSize.y ) // draw grid points
{
yg = wxRound( jj * screen_grid_size.y );
ypos = screen->Scale( yg );
if( ypos > screenSize.y )
if( y > bottom )
break;
tmpDC.DrawPoint( 0, ypos );
tmpDC.DrawPoint( 0, wxRound( y ) );
}
// Use the layer bitmap itself as a mask when blitting.
......@@ -922,20 +703,12 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* DC )
tmpBM.SetMask( new wxMask( tmpBM, MakeColour( g_DrawBgColor ) ) );
tmpDC.SelectObject( tmpBM );
ypos = GRMapY( org.y );
for( ii = 0; ; ii += increment )
double right = m_ClipBox.GetRight();
for( double x = (double) org.x; x <= right; x += gridSize.x )
{
xg = wxRound( ii * screen_grid_size.x );
if( xg > size.x )
break;
xpos = GRMapX( org.x + xg );
if( xpos < m_ClipBox.GetOrigin().x) // column not in active screen area.
continue;
if( xpos > m_ClipBox.GetEnd().x) // end of active area reached.
break;
DC->Blit( xpos, ypos, 1, screenSize.y, &tmpDC, 0, 0, wxCOPY, true );
DC->Blit( wxRound( x ), org.y, 1, m_ClipBox.GetHeight(), &tmpDC, 0, 0, wxCOPY, true );
}
#endif
}
......@@ -978,12 +751,12 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, int aDrawMode )
void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, int aDrawMode )
{
BASE_SCREEN* screen = GetScreen();
if( !m_Parent->m_Draw_Grid_Axis
|| ( screen->m_GridOrigin.x == 0
&& screen->m_GridOrigin.y == 0 ) )
|| ( screen->m_GridOrigin.x == 0 && screen->m_GridOrigin.y == 0 ) )
return;
int Color = m_Parent->GetGridColor();
int Color = m_Parent->GetGridColor();
GRSetDrawMode( aDC, aDrawMode );
......@@ -1070,8 +843,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
|| !rect.Contains( event.GetPosition() ) )
{
#if 0
wxLogDebug( wxT( "OnMouseWheel() position(%d, %d) " ) \
wxT( "rectangle(%d, %d, %d, %d)" ),
wxLogDebug( wxT( "OnMouseWheel() position(%d, %d) rectangle(%d, %d, %d, %d)" ),
event.GetPosition().x, event.GetPosition().y,
rect.x, rect.y, rect.width, rect.height );
#endif
......@@ -1079,8 +851,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
return;
}
GetScreen()->m_Curseur =
CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
GetScreen()->m_Curseur = CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
......@@ -1132,6 +903,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
* in order to avoid spurious block commands.
*/
static int MinDragEventCount;
if( event.Leaving() )
{
m_CanStartBlock = -1;
......@@ -1145,8 +917,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
else
return;
if( !event.IsButton() && !event.Moving()
&& !event.Dragging() && !localkey )
if( !event.IsButton() && !event.Moving() && !event.Dragging() && !localkey )
{
return;
}
......@@ -1178,24 +949,24 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute the cursor position in screen (device) units. */
screen->m_MousePositionInPixels = CalcUnscrolledPosition( event.GetPosition() );
wxPoint pos = CalcUnscrolledPosition( event.GetPosition() );
/* Compute the cursor position in drawing (logical) units. */
screen->m_MousePosition =
CursorRealPosition( CalcUnscrolledPosition( event.GetPosition() ) );
screen->m_MousePosition = CursorRealPosition( pos );
INSTALL_DC( DC, this );
INSTALL_UNBUFFERED_DC( DC, this );
DC.SetBackground( *wxBLACK_BRUSH );
int kbstat = 0;
DC.SetBackground( *wxBLACK_BRUSH );
g_KeyPressed = localkey;
if( event.ShiftDown() )
kbstat |= GR_KB_SHIFT;
if( event.ControlDown() )
kbstat |= GR_KB_CTRL;
if( event.AltDown() )
kbstat |= GR_KB_ALT;
......@@ -1204,7 +975,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// Calling Double Click and Click functions :
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{
m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels );
m_Parent->OnLeftDClick( &DC, pos );
// inhibit a response to the mouse left button release,
// because we have a double click, and we do not want a new
......@@ -1215,9 +986,8 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
// A block command is in progress: a left up is the end of block
// or this is the end of a double click, already seen
if( screen->m_BlockLocate.m_State==STATE_NO_BLOCK
&& !s_IgnoreNextLeftButtonRelease )
m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );
if( screen->m_BlockLocate.m_State==STATE_NO_BLOCK && !s_IgnoreNextLeftButtonRelease )
m_Parent->OnLeftClick( &DC, pos );
s_IgnoreNextLeftButtonRelease = false;
}
......@@ -1232,21 +1002,17 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
s_IgnoreNextLeftButtonRelease = false;
}
if( event.ButtonUp( wxMOUSE_BTN_MIDDLE )
&& (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) )
if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) )
{
// The middle button has been released, with no block command:
// We use it for a zoom center at cursor position command
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED,
ID_POPUP_ZOOM_CENTER );
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
cmd.SetEventObject( this );
GetEventHandler()->ProcessEvent( cmd );
}
/* Calling the general function on mouse changes (and pseudo key commands) */
m_Parent->GeneralControle( &DC, screen->m_MousePositionInPixels );
m_Parent->GeneralControle( &DC, pos );
/*******************************/
/* Control of block commands : */
......@@ -1287,6 +1053,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
}
if( event.LeftDown() || event.MiddleDown() )
{
if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
......@@ -1301,8 +1068,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
&& ManageCurseur == NULL
&& ForceCloseManageCurseur == NULL )
{
// Mouse is dragging: if no block in progress, start a block
// command.
// Mouse is dragging: if no block in progress, start a block command.
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{
// Start a block command
......@@ -1345,19 +1111,17 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
*/
#define BLOCK_MINSIZE_LIMIT 1
bool BlockIsSmall =
( ABS( screen->Scale( screen->m_BlockLocate.GetWidth() ) )
< BLOCK_MINSIZE_LIMIT)
&& ( ABS( screen->Scale( screen->m_BlockLocate.GetHeight() ) )
< BLOCK_MINSIZE_LIMIT);
( ABS( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
&& ( ABS( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
if( (screen->m_BlockLocate.m_State
!= STATE_NO_BLOCK) && BlockIsSmall )
if( (screen->m_BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall )
{
if( ForceCloseManageCurseur )
{
ForceCloseManageCurseur( this, &DC );
m_AutoPAN_Request = false;
}
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
}
else if( screen->m_BlockLocate.m_State == STATE_BLOCK_END )
......@@ -1365,6 +1129,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_AutoPAN_Request = false;
m_Parent->HandleBlockEnd( &DC );
SetCursor( m_PanelCursor = m_PanelDefaultCursor );
if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
{
m_AutoPAN_Request = TRUE;
......@@ -1375,8 +1140,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
}
// End of block command on a double click
// To avoid an unwanted block move command if the mouse is moved while
// double clicking
// To avoid an unwanted block move command if the mouse is moved while double clicking
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{
if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
......@@ -1440,7 +1204,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
if( (localkey > GR_KB_CTRL) && (localkey <= GR_KB_CTRL+26) )
localkey += 'A' - 1;
INSTALL_DC( DC, this );
INSTALL_UNBUFFERED_DC( DC, this );
BASE_SCREEN* Screen = GetScreen();
......@@ -1464,12 +1228,7 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
/* Some key commands use the current mouse position: refresh it */
pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() );
/* Compute cursor position in screen units (pixel) including the
* current scroll bar position. Also known as device units to wxDC. */
Screen->m_MousePositionInPixels = pos;
/* Compute the cursor position in drawing units. Also known as logical units
* to wxDC. */
// Compute the cursor position in drawing units. Also known as logical units to wxDC.
Screen->m_MousePosition = CursorRealPosition( pos );
m_Parent->GeneralControle( &DC, pos );
......@@ -1519,10 +1278,13 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event )
if( x < 0 )
x = 0;
if( y < 0 )
y = 0;
if( x > maxX )
x = maxX;
if( y > maxY )
y = maxY;
......@@ -1534,10 +1296,11 @@ void EDA_DRAW_PANEL::UnManageCursor( int id, int cursor, const wxString& title )
{
if( ManageCurseur && ForceCloseManageCurseur )
{
INSTALL_DC( dc, this );
INSTALL_UNBUFFERED_DC( dc, this );
ForceCloseManageCurseur( this, &dc );
m_AutoPAN_Request = false;
}
if( id != -1 && cursor != -1 )
{
wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );
......
......@@ -287,10 +287,10 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aPanel )
{
int xm, ym, ll, xc, yc;
ll = aPanel->GetScreen()->Scale( ABS( dx ) );
ll = ABS( dx );
xc = GRMapX( current_char_pos.x );
yc = GRMapY( current_char_pos.y );
xc = current_char_pos.x;
yc = current_char_pos.y;
x0 = aPanel->m_ClipBox.GetX() - ll;
y0 = aPanel->m_ClipBox.GetY() - ll;
......@@ -343,11 +343,12 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
}
// 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;
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single graphic line */
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 )
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* graphic line */
if( aSize.x < 3 )
{
/* draw the text as a line always vertically centered */
wxPoint end( current_char_pos.x + dx, current_char_pos.y );
......
......@@ -63,33 +63,15 @@ static void ClipAndDrawFilledPoly( EDA_Rect * ClipBox, wxDC * DC, wxPoint Points
* ( GRSCircle is called by GRCircle for instance) after mapping coordinates
* from user units to screen units(pixels coordinates)
*/
static void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color );
static void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor );
static void GRSMixedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
static void GRSDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, int Color );
static void GRSDashedLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2,
int y2, int width, int Color );
static void GRSLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color );
static void GRSMoveTo( int x, int y );
static void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color );
static void GRSArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color );
static void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int width, int Color, int BgColor );
static void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, int Color );
static void GRSLineArray( EDA_Rect * aClipBox, wxDC * aDC, std::vector<wxPoint>& aLines,
int aWidth, int aColor );
static void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1,
int x2, int y2, int aWidth, int aColor,
wxPenStyle aStyle = wxPENSTYLE_SOLID );
/**/
extern BASE_SCREEN* ActiveScreen;
static int GRLastMoveToX, GRLastMoveToY;
static bool s_ForceBlackPen; /* if true: draws in black instead of
* color for printing. */
......@@ -106,73 +88,6 @@ static int s_DC_lastbrushfill = -1;
static wxDC* s_DC_lastDC = NULL;
/* Local functions: */
static void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1,
int x2, int y2, int aWidth, int aColor,
wxPenStyle aStyle = wxPENSTYLE_SOLID );
/*
* Macro clipping the trace of a line:
* Line (x1, y1 x2, y2) is clipped to remain within
* (Xcliplo, ycliplo xcliphi, ycliphi) (global variables, local to this file)
* This is necessary because under WIN95 coord trace
* (Although an int has 32 bits) are truncated to 16 bits (stupid)
*/
static inline int USCALE( unsigned int arg, unsigned int num, unsigned int den )
{
#ifndef USE_WX_ZOOM
int ii;
ii = (int) ( ( (float) arg * num ) / den );
return ii;
#else
return arg;
#endif
}
static int inline ZoomValue( int val )
{
return ActiveScreen->Scale( val );
}
/****************************************/
/* External reference for the mappings. */
/****************************************/
int GRMapX( int x )
{
#ifndef USE_WX_ZOOM
int coord = x - ActiveScreen->m_DrawOrg.x;
coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.x;
return coord;
#else
return x;
#endif
}
int GRMapY( int y )
{
#ifndef USE_WX_ZOOM
int coord = y - ActiveScreen->m_DrawOrg.y;
coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.y;
return coord;
#else
return y;
#endif
}
#define WHEN_OUTSIDE return true;
#define WHEN_INSIDE
#if defined( USE_WX_ZOOM )
// currently only used if USE_WX_ZOOM is defined.
/**
* Test if any part of a line falls within the bounds of a rectangle.
*
......@@ -257,8 +172,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
/* If we're here, something has gone terribly wrong. */
#if DEBUG_DUMP_CLIP_ERROR_COORDS
wxLogDebug( wxT(
"Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ),
wxLogDebug( wxT( "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ),
tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 );
#endif
return false;
......@@ -312,8 +226,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
/* If we're here, something has gone terribly wrong. */
#if DEBUG_DUMP_CLIP_ERROR_COORDS
wxLogDebug( wxT(
"Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ),
wxLogDebug( wxT( "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ),
tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 );
#endif
return false;
......@@ -391,8 +304,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
* something has gone terribly wrong. */
#if DEBUG_DUMP_CLIP_ERROR_COORDS
if( haveFirstPoint )
wxLogDebug( wxT(
"Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ),
wxLogDebug( wxT( "Line (%d,%d):(%d,%d) in rectangle (%d,%d,%d,%d) clipped to (%d,%d,%d,%d)" ),
tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 );
#endif
}
......@@ -408,115 +320,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
}
#endif // if defined( USE_WX_ZOOM )
/**
* Function clip_line
* @return bool - true when WHEN_OUTSIDE fires, else false.
*/
static inline bool clip_line( int& x1, int& y1, int& x2, int& y2 )
{
int temp;
if( x1 > x2 )
{
EXCHG( x1, x2 );
EXCHG( y1, y2 );
}
if( (x2 < xcliplo) || (x1 > xcliphi) )
{
WHEN_OUTSIDE;
}
if( y1 < y2 )
{
if( (y2 < ycliplo) || (y1 > ycliphi) )
{
WHEN_OUTSIDE;
}
if( y1 < ycliplo )
{
temp = USCALE( (x2 - x1), (ycliplo - y1), (y2 - y1) );
if( (x1 += temp) > xcliphi )
{
WHEN_OUTSIDE;
}
y1 = ycliplo;
WHEN_INSIDE;
}
if( y2 > ycliphi )
{
temp = USCALE( (x2 - x1), (y2 - ycliphi), (y2 - y1) );
if( (x2 -= temp) < xcliplo )
{
WHEN_OUTSIDE;
}
y2 = ycliphi;
WHEN_INSIDE;
}
if( x1 < xcliplo )
{
temp = USCALE( (y2 - y1), (xcliplo - x1), (x2 - x1) );
y1 += temp;
x1 = xcliplo;
WHEN_INSIDE;
}
if( x2 > xcliphi )
{
temp = USCALE( (y2 - y1), (x2 - xcliphi), (x2 - x1) );
y2 -= temp;
x2 = xcliphi;
WHEN_INSIDE;
}
}
else
{
if( (y1 < ycliplo) || (y2 > ycliphi) )
{
WHEN_OUTSIDE;
}
if( y1 > ycliphi )
{
temp = USCALE( (x2 - x1), (y1 - ycliphi), (y1 - y2) );
if( (x1 += temp) > xcliphi )
{
WHEN_OUTSIDE;
}
y1 = ycliphi;
WHEN_INSIDE;
}
if( y2 < ycliplo )
{
temp = USCALE( (x2 - x1), (ycliplo - y2), (y1 - y2) );
if( (x2 -= temp) < xcliplo )
{
WHEN_OUTSIDE;
}
y2 = ycliplo;
WHEN_INSIDE;
}
if( x1 < xcliplo )
{
temp = USCALE( (y1 - y2), (xcliplo - x1), (x2 - x1) );
y1 -= temp;
x1 = xcliplo;
WHEN_INSIDE;
}
if( x2 > xcliphi )
{
temp = USCALE( (y1 - y2), (x2 - xcliphi), (x2 - x1) );
y2 += temp;
x2 = xcliphi;
WHEN_INSIDE;
}
}
return false;
}
static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int Color, int width = 1 )
{
GRLastMoveToX = x2;
......@@ -535,12 +339,7 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
xcliphi += width;
ycliphi += width;
#if defined( USE_WX_ZOOM )
if( clipLine( ClipBox, x1, y1, x2, y2 ) )
#else
if( clip_line( x1, y1, x2, y2 ) )
#endif
return;
}
......@@ -576,9 +375,9 @@ void GRSetColorPen( wxDC* DC, int Color, int width, wxPenStyle style )
}
if( s_DC_lastcolor != Color
|| s_DC_lastwidth != width
|| s_DC_lastpenstyle != style
|| s_DC_lastDC != DC )
|| s_DC_lastwidth != width
|| s_DC_lastpenstyle != style
|| s_DC_lastDC != DC )
{
wxPen pen;
......@@ -604,8 +403,8 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
Color = BLACK;
if( s_DC_lastbrushcolor != Color
|| s_DC_lastbrushfill != fill
|| s_DC_lastDC != DC )
|| s_DC_lastbrushfill != fill
|| s_DC_lastDC != DC )
{
wxBrush DrawBrush;
DrawBrush.SetColour( MakeColour( Color ) );
......@@ -697,12 +496,6 @@ void GRSetDrawMode( wxDC* DC, int draw_mode )
void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
{
GRSPutPixel( ClipBox, DC, GRMapX( x ), GRMapY( y ), Color );
}
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
{
if( ClipBox && !ClipBox->Contains( x, y ) )
return;
......@@ -724,56 +517,23 @@ void GRLine( EDA_Rect* ClipBox,
int width,
int Color )
{
GRSLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), ZoomValue( width ), Color );
}
void GRLine( EDA_Rect* aClipBox,
wxDC* aDC,
wxPoint aStart,
wxPoint aEnd,
int aWidth,
int aColor )
{
GRSLine( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
ZoomValue( aWidth ), aColor );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
GRLastMoveToX = x2;
GRLastMoveToY = y2;
}
/*
* Draw a dashed line, in screen space.
*/
void GRSDashedLine( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int Color )
void GRLine( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
GRSLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width );
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
}
void GRSDashedLineTo( EDA_Rect* ClipBox,
wxDC* DC,
int x2,
int y2,
int width,
int Color )
void GRDashedLineTo( EDA_Rect* ClipBox, wxDC* DC, int x2, int y2, int width, int Color )
{
s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width, Color );
GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width, Color );
s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width );
GRLastMoveToX = x2;
......@@ -781,21 +541,6 @@ void GRSDashedLineTo( EDA_Rect* ClipBox,
}
/*
* Draw a dashed line, in object space.
*/
void GRDashedLineTo( EDA_Rect* ClipBox,
wxDC* DC,
int x2,
int y2,
int width,
int Color )
{
GRSDashedLineTo( ClipBox, DC, GRMapX( x2 ), GRMapY( y2 ),
ZoomValue( width ), Color );
}
void GRDashedLine( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
......@@ -805,8 +550,13 @@ void GRDashedLine( EDA_Rect* ClipBox,
int width,
int Color )
{
GRSDashedLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), ZoomValue( width ), Color );
GRLastMoveToX = x2;
GRLastMoveToY = y2;
s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width );
}
......@@ -815,8 +565,8 @@ void GRDashedLine( EDA_Rect* ClipBox,
*/
void GRMoveTo( int x, int y )
{
GRLastMoveToX = GRMapX( x );
GRLastMoveToY = GRMapY( y );
GRLastMoveToX = x;
GRLastMoveToY = y;
}
......@@ -827,51 +577,18 @@ void GRLineTo( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int width, int Color )
{
int GRLineToX, GRLineToY;
GRLineToX = GRMapX( x ); GRLineToY = GRMapY( y );
GRSLine( ClipBox,
DC,
GRLastMoveToX,
GRLastMoveToY,
GRLineToX,
GRLineToY,
ZoomValue( width ),
Color );
}
GRLineToX = x;
GRLineToY = y;
/*
* Draw a mixed line, in object space.
*/
void GRMixedLine( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int Color )
{
GRSMixedLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), ZoomValue( width ), Color );
GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, width, Color );
}
/*
* Draw a mixed line, in screen (Pixels) space.
* Currently, draw a line (not a mixed line)
* Perhaps this function is not very useful.
*/
void GRSMixedLine( 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,
int width, int Color )
{
GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH );
GRSLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
GRSetColorPen( DC, Color, width );
}
......@@ -886,24 +603,6 @@ void GRSMoveTo( int x, int y )
}
/*
* Draw line to a new position, in screen (pixels) space.
*/
void GRSLine( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int Color )
{
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
GRLastMoveToX = x2;
GRLastMoveToY = y2;
}
/**
* Function GRLineArray
* draws an array of lines (not a polygon).
......@@ -914,26 +613,11 @@ void GRSLine( EDA_Rect* ClipBox,
* @param aColor = an index into our color table of RGB colors.
* @see EDA_Colors and colors.h
*/
void GRLineArray( EDA_Rect* aClipBox, wxDC* aDC,
std::vector<wxPoint>& aLines,
void GRLineArray( EDA_Rect* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
int aWidth, int aColor )
{
for( unsigned i = 0; i < aLines.size(); i++ )
{
aLines[i].x = GRMapX( aLines[i].x );
aLines[i].y = GRMapY( aLines[i].y );
}
aWidth = ZoomValue( aWidth );
GRSLineArray( aClipBox, aDC, aLines, aWidth, aColor );
}
void GRSLineArray( EDA_Rect* aClipBox, wxDC* aDC,
std::vector<wxPoint>& aLines,
int aWidth, int aColor )
{
GRSetColorPen( aDC, aColor, aWidth );
#if defined( USE_WX_GRAPHICS_CONTEXT ) || defined(__WXMAC__)
wxGraphicsContext* gc = wxGraphicsContext::Create( aDC );
wxASSERT( gc );
......@@ -961,71 +645,12 @@ void GRSLineArray( EDA_Rect* aClipBox, wxDC* aDC,
GRLastMoveToY = aLines[i].y;
i++;
}
#endif
}
/*
* Draw segment with rounded ends in object space.
*/
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, int Color )
{
GRSCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), ZoomValue( width ), ZoomValue( aPenSize ), Color );
}
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color )
{
GRSCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), ZoomValue( width ), 0, Color );
}
void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, int aColor )
{
GRSCSegm( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
ZoomValue( aWidth ), 0, aColor );
}
/*
* Draw segment (full) with rounded ends in object space (real coords.).
*/
void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color )
{
WinClipAndDrawLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), Color, ZoomValue( width ) );
}
void GRFilledSegment( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, int aColor )
{
WinClipAndDrawLine( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
aColor, ZoomValue( aWidth ) );
}
/*
* Draw segment with rounded ends (SKETCH mode) in screen space
*/
void GRSCSegm( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int aPenSize,
int Color )
{
long radius;
int dwx, dwy;
......@@ -1051,12 +676,7 @@ void GRSCSegm( EDA_Rect* ClipBox,
xcliphi += width;
ycliphi += width;
#if defined( USE_WX_ZOOM )
if( clipLine( ClipBox, x1, y1, x2, y2 ) )
#else
if( clip_line( x1, y1, x2, y2 ) )
#endif
return;
}
......@@ -1182,6 +802,37 @@ void GRSCSegm( EDA_Rect* ClipBox,
}
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color )
{
GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
}
void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, int aColor )
{
GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
}
/*
* Draw segment (full) with rounded ends in object space (real coords.).
*/
void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color )
{
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
}
void GRFilledSegment( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, int aColor )
{
WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aColor, aWidth );
}
static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
{
if( !ClipBox )
......@@ -1302,14 +953,14 @@ static void GRSClosedPoly( EDA_Rect* ClipBox,
/* Close the polygon. */
if( aPoints[aPointCount - 1] != aPoints[0] )
{
GRSLine( ClipBox,
DC,
aPoints[0].x,
aPoints[0].y,
aPoints[aPointCount - 1].x,
aPoints[aPointCount - 1].y,
width,
Color );
GRLine( ClipBox,
DC,
aPoints[0].x,
aPoints[0].y,
aPoints[aPointCount - 1].x,
aPoints[aPointCount - 1].y,
width,
Color );
}
}
}
......@@ -1321,13 +972,6 @@ static void GRSClosedPoly( EDA_Rect* ClipBox,
void GRPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, int Color, int BgColor )
{
for( int i = 0; i<n; ++i )
{
Points[i].x = GRMapX( Points[i].x );
Points[i].y = GRMapY( Points[i].y );
}
width = ZoomValue( width );
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
......@@ -1345,81 +989,54 @@ void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
void GRClosedPoly( EDA_Rect* ClipBox, wxDC* DC, int n, wxPoint Points[],
bool Fill, int width, int Color, int BgColor )
{
for( int i = 0; i<n; ++i )
{
Points[i].x = GRMapX( Points[i].x );
Points[i].y = GRMapY( Points[i].y );
}
width = ZoomValue( width );
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
/*
* Draw a circle, in object space.
*/
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color )
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int r, int width, int Color )
{
int cx = GRMapX( x );
int cy = GRMapY( y );
int radius = ZoomValue( r );
/* Clip circles off screen. */
if( ClipBox )
{
int x0, y0, xm, ym;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
GRSCircle( ClipBox, DC, cx, cy, radius, 0, Color );
}
if( xc < ( x0 - r - width ) )
return;
if( yc < ( y0 - r - width ) )
return;
/*
* Draw a circle in object space.
*/
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color )
{
r = ZoomValue( r );
width = ZoomValue( width );
GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color );
}
if( xc > ( r + xm + width ) )
return;
if( yc > ( r + ym + width ) )
return;
}
/*
* Draw a circle in object space.
*/
void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor )
{
aRadius = ZoomValue( aRadius );
aWidth = ZoomValue( aWidth );
GRSCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, aWidth, aColor );
GRSetColorPen( DC, Color, width );
GRSetBrush( DC, Color, false );
DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
}
/*
* Draw a filled circle, in object space.
*/
void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor )
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color )
{
r = ZoomValue( r );
width = ZoomValue( width );
GRSFilledCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width,
Color, BgColor );
GRCircle( ClipBox, DC, x, y, r, 0, Color );
}
/*
* Draw a filled circle, in object space.
*/
void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor )
void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor )
{
aRadius = ZoomValue( aRadius );
GRSFilledCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, 0,
aColor, aColor );
GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
}
/*
* Draw a filled circle, in drawing space.
*/
void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor )
void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor )
{
/* Clip circles off screen. */
if( ClipBox )
......@@ -1445,38 +1062,9 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
}
/*
* Draw a circle in drawing space.
*/
void GRSCircle( EDA_Rect* ClipBox,
wxDC* DC,
int xc,
int yc,
int r,
int width,
int Color )
void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor )
{
/* Clip circles off screen. */
if( ClipBox )
{
int x0, y0, xm, ym;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
if( xc < ( x0 - r - width ) )
return;
if( yc < ( y0 - r - width ) )
return;
if( xc > ( r + xm + width ) )
return;
if( yc > ( r + ym + width ) )
return;
}
GRSetColorPen( DC, Color, width );
GRSetBrush( DC, Color, false );
DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
}
......@@ -1486,8 +1074,7 @@ void GRSCircle( EDA_Rect* ClipBox,
void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int Color )
{
GRSArc1( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), GRMapX( xc ), GRMapY( yc ), 0, Color );
GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
}
......@@ -1496,28 +1083,6 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
*/
void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color )
{
GRSArc1( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
GRMapY( y2 ), GRMapX( xc ), GRMapY( yc ), ZoomValue( width ),
Color );
}
void GRArc1( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
wxPoint aCenter, int aWidth, int aColor )
{
GRSArc1( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
GRMapX( aCenter.x ), GRMapY( aCenter.y ), ZoomValue( aWidth ),
aColor );
}
/*
* Draw an arc, width = width, in screen space.
*/
void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, int Color )
{
/* Clip arcs off screen. */
if( ClipBox )
......@@ -1544,66 +1109,27 @@ void GRSArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
/*
* Draw an arc in screen space.
*/
void GRSArc( EDA_Rect* ClipBox,
wxDC* DC,
int xc,
int yc,
int StAngle,
int EndAngle,
int r,
int width,
int Color )
void GRArc1( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
wxPoint aCenter, int aWidth, int aColor )
{
int x1, y1, x2, y2;
/* Clip arcs off screen. */
if( ClipBox )
{
int x0, y0, xm, ym;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
if( xc < ( x0 - r - width ) )
return;
if( yc < ( y0 - r - width ) )
return;
if( xc > ( r + xm + width ) )
return;
if( yc > ( r + ym + width ) )
return;
}
x1 = r;
y1 = 0;
RotatePoint( &x1, &y1, EndAngle );
x2 = r;
y2 = 0;
RotatePoint( &x2, &y2, StAngle );
GRSetColorPen( DC, Color, width );
GRSetBrush( DC, Color );
DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
aWidth, aColor );
}
/*
* Draw an filled arc in screen space.
* Draw a filled arc in drawing space.
*/
void GRSFilledArc( EDA_Rect* ClipBox,
wxDC* DC,
int xc,
int yc,
int StAngle,
int EndAngle,
int r,
int width,
int Color,
int BgColor )
void GRFilledArc( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int StAngle,
int EndAngle,
int r,
int width,
int Color,
int BgColor )
{
int x1, y1, x2, y2;
......@@ -1615,13 +1141,17 @@ void GRSFilledArc( EDA_Rect* ClipBox,
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
if( xc < ( x0 - r - 1 ) )
if( x < ( x0 - r - 1 ) )
return;
if( yc < ( y0 - r - 1 ) )
if( y < ( y0 - r - 1 ) )
return;
if( xc > ( r + xm + 1 ) )
if( x > ( r + xm + 1 ) )
return;
if( yc > ( r + ym + 1 ) )
if( y > ( r + ym + 1 ) )
return;
}
......@@ -1635,35 +1165,14 @@ void GRSFilledArc( EDA_Rect* ClipBox,
GRSetBrush( DC, BgColor, FILLED );
GRSetColorPen( DC, Color, width );
DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
}
/*
* Draw a filled arc in drawing space.
*/
void GRFilledArc( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int StAngle,
int EndAngle,
int r,
int width,
int Color,
int BgColor )
{
width = ZoomValue( width );
GRSFilledArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), StAngle, EndAngle,
ZoomValue( r ), width, Color, BgColor );
DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
}
void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y,
int StAngle, int EndAngle, int r, int Color, int BgColor )
{
GRSFilledArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), StAngle, EndAngle,
ZoomValue( r ), 0, Color, BgColor );
GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
}
......@@ -1678,13 +1187,15 @@ void GRArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle,
/* Clip arcs off screen */
if( ClipBox )
{
int radius = ZoomValue( r ) + 1;
int radius = r + 1;
int x0, y0, xm, ym, x, y;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
x = GRMapX( xc ); y = GRMapY( yc );
x = xc;
y = yc;
if( x < ( x0 - radius ) )
return;
if( y < ( y0 - radius ) )
......@@ -1705,8 +1216,7 @@ void GRArc( EDA_Rect* ClipBox, wxDC* DC, int xc, int yc, int StAngle,
GRSetColorPen( DC, Color );
GRSetBrush( DC, Color, false );
DC->DrawArc( GRMapX( xc + x1 ), GRMapY( yc - y1 ), GRMapX( xc + x2 ),
GRMapY( yc - y2 ), GRMapX( xc ), GRMapY( yc ) );
DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
}
......@@ -1723,8 +1233,41 @@ void GRArc( EDA_Rect* ClipBox,
int width,
int Color )
{
GRSArc( ClipBox, DC, GRMapX( x ), GRMapY( y ), StAngle, EndAngle,
ZoomValue( r ), ZoomValue( width ), Color );
int x1, y1, x2, y2;
/* Clip arcs off screen. */
if( ClipBox )
{
int x0, y0, xm, ym;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
if( x < ( x0 - r - width ) )
return;
if( y < ( y0 - r - width ) )
return;
if( x > ( r + xm + width ) )
return;
if( y > ( r + ym + width ) )
return;
}
x1 = r;
y1 = 0;
RotatePoint( &x1, &y1, EndAngle );
x2 = r;
y2 = 0;
RotatePoint( &x2, &y2, StAngle );
GRSetColorPen( DC, Color, width );
GRSetBrush( DC, Color );
DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
}
......@@ -1733,21 +1276,16 @@ void GRArc( EDA_Rect* ClipBox,
*/
void GRRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, int aColor )
{
x1 = GRMapX( x1 );
y1 = GRMapY( y1 );
x2 = GRMapX( x2 );
y2 = GRMapY( y2 );
GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
}
void GRRectPs( EDA_Rect* aClipBox, wxDC* aDC, const EDA_Rect& aRect, int aColor, wxPenStyle aStyle )
{
int x1 = GRMapX( aRect.GetX() );
int y1 = GRMapY( aRect.GetY() );
int x2 = GRMapX( aRect.GetRight() );
int y2 = GRMapY( aRect.GetBottom() );
int x1 = aRect.GetX();
int y1 = aRect.GetY();
int x2 = aRect.GetRight();
int y2 = aRect.GetBottom();
GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor, aStyle );
}
......@@ -1758,26 +1296,18 @@ void GRRectPs( EDA_Rect* aClipBox, wxDC* aDC, const EDA_Rect& aRect, int aColor,
*/
void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color )
{
x1 = GRMapX( x1 );
y1 = GRMapY( y1 );
x2 = GRMapX( x2 );
y2 = GRMapY( y2 );
width = ZoomValue( width );
GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
}
void GRRect( EDA_Rect* aClipBox, wxDC* aDC, const EDA_Rect& aRect, int aWidth, int aColor )
{
int x1 = GRMapX( aRect.GetX() );
int y1 = GRMapY( aRect.GetY() );
int x2 = GRMapX( aRect.GetRight() );
int y2 = GRMapY( aRect.GetBottom() );
int x1 = aRect.GetX();
int y1 = aRect.GetY();
int x2 = aRect.GetRight();
int y2 = aRect.GetBottom();
int width = ZoomValue( aWidth );
GRSRect( aClipBox, aDC, x1, y1, x2, y2, width, aColor );
GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
}
......@@ -1787,11 +1317,6 @@ void GRRect( EDA_Rect* aClipBox, wxDC* aDC, const EDA_Rect& aRect, int aWidth, i
void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int Color, int BgColor )
{
x1 = GRMapX( x1 );
y1 = GRMapY( y1 );
x2 = GRMapX( x2 );
y2 = GRMapY( y2 );
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
}
......@@ -1802,12 +1327,6 @@ void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color, int BgColor )
{
x1 = GRMapX( x1 );
y1 = GRMapY( y1 );
x2 = GRMapX( x2 );
y2 = GRMapY( y2 );
width = ZoomValue( width );
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
}
......@@ -1821,6 +1340,7 @@ void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
{
if( x1 > x2 )
EXCHG( x1, x2 );
if( y1 > y2 )
EXCHG( y1, y2 );
......@@ -1833,15 +1353,19 @@ void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
if( x1 > xmax )
return;
if( x2 < xmin )
return;
if( y1 > ymax )
return;
if( y2 < ymin )
return;
}
GRSetColorPen( aDC, aColor, aWidth, aStyle );
if( ( x1 == x2 ) || ( y1 == y2 ) )
aDC->DrawLine( x1, y1, x2, y2 );
else
......@@ -1852,14 +1376,15 @@ void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
}
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int Color, int BgColor )
{
if( x1 > x2 )
EXCHG( x1, x2 );
if( y1 > y2 )
EXCHG( y1, y2 );
if( ClipBox )
{
int xmin = ClipBox->GetX();
......@@ -1879,15 +1404,19 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC,
// Clipping coordinates
if( x1 < xmin )
x1 = xmin - 1;
if( y1 < ymin )
y1 = ymin - 1;
if( x2 > xmax )
x2 = xmax + 1;
if( y2 > ymax )
y2 = ymax + 1;
}
GRSetColorPen( DC, Color, width );
if( ( x1 == x2 ) || ( y1 == y2 ) )
DC->DrawLine( x1, y1, x2, y2 );
else
......@@ -1914,10 +1443,8 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC,
* the polygon is drawn, but not clipped
*/
#include "SutherlandHodgmanClipPoly.h"
void ClipAndDrawFilledPoly( EDA_Rect* aClipBox,
wxDC* aDC,
wxPoint aPoints[],
int n )
void ClipAndDrawFilledPoly( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPoints[], int n )
{
if( aClipBox == NULL )
{
......@@ -1932,23 +1459,19 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox,
inputPolygon.clear();
outputPolygon.clear();
clippedPolygon.clear();
for( int ii = 0; ii < n; ii++ )
inputPolygon.push_back( PointF( (REAL) aPoints[ii].x,
(REAL) aPoints[ii].y ) );
inputPolygon.push_back( PointF( (REAL) aPoints[ii].x, (REAL) aPoints[ii].y ) );
RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
(REAL) aClipBox->GetWidth(),
(REAL) aClipBox->GetHeight() );
(REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() );
SutherlandHodgman sh( window );
sh.Clip( inputPolygon, outputPolygon );
for( cpointIterator cit = outputPolygon.begin();
cit != outputPolygon.end();
++cit )
for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
{
clippedPolygon.push_back( wxPoint( wxRound( cit->X ),
wxRound( cit->Y ) ) );
clippedPolygon.push_back( wxPoint( wxRound( cit->X ), wxRound( cit->Y ) ) );
}
if( clippedPolygon.size() )
......
......@@ -17,33 +17,30 @@
#include "kicad_device_context.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
* @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 )
void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer )
{
PutOnGrid( &(GetBaseScreen()->m_Curseur) );
AdjustScrollBars();
#if !(defined(__WXMAC__) && defined(USE_WX_ZOOM))
/* We do not use here DrawPanel->Refresh() because
* the redraw is delayed and the mouse events (from MouseToCursorSchema ot others)
* during this delay create problems: the mouse cursor position is false in calculations.
* TODO: see exactly how the mouse creates problems when moving during refresh
* use Refresh() and update() do not change problems
#if !defined(__WXMAC__)
/* DrawPanel->Refresh() is not used here because the redraw is delayed and the mouse
* events (from MouseToCursorSchema ot others) during this delay create problems: the
* mouse cursor position is false in calculations. TODO: see exactly how the mouse
* creates problems when moving during refresh use Refresh() and update() do not change
* problems
*/
INSTALL_DC( dc, DrawPanel );
DrawPanel->SetClipBox( dc );
DrawPanel->ReDraw( &dc, DrawPanel->m_DisableEraseBG ? false : true );
#else
DrawPanel->Refresh();
DrawPanel->Update();
#endif
/* Move the mouse cursor to the on grid graphic cursor position */
if( ToMouse == TRUE )
if( aWarpPointer )
DrawPanel->MouseToCursorSchema();
}
......@@ -77,7 +74,7 @@ void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize )
void EDA_DRAW_FRAME::Zoom_Automatique( bool move_mouse_cursor )
{
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 )
GetBaseScreen()->SetScalingFactor( bestscale );
GetBaseScreen()->m_Curseur = Rect.Centre();
Recadre_Trace( TRUE );
RedrawScreen( TRUE );
}
......@@ -130,7 +127,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( id == ID_ZOOM_IN )
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
if( screen->SetPreviousZoom() )
Recadre_Trace( zoom_at_cursor );
RedrawScreen( zoom_at_cursor );
break;
case ID_POPUP_ZOOM_OUT:
......@@ -142,7 +139,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if( id == ID_ZOOM_OUT )
screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
if( screen->SetNextZoom() )
Recadre_Trace( zoom_at_cursor );
RedrawScreen( zoom_at_cursor );
break;
case ID_ZOOM_REDRAW:
......@@ -150,7 +147,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break;
case ID_POPUP_ZOOM_CENTER:
Recadre_Trace( true );
RedrawScreen( true );
break;
case ID_ZOOM_PAGE:
......@@ -174,7 +171,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
return;
}
if( screen->SetZoom( screen->m_ZoomList[i] ) )
Recadre_Trace( true );
RedrawScreen( true );
}
UpdateStatusBar();
......
......@@ -492,7 +492,7 @@ void WinEDA_CvpcbFrame::DisplayModule( wxCommandEvent& event )
{
CreateScreenCmp();
DrawFrame->AdjustScrollBars();
DrawFrame->Recadre_Trace( FALSE );
DrawFrame->RedrawScreen( FALSE );
}
......
......@@ -236,6 +236,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
GetScreen()->BreakSegmentsOnJunctions();
// fall through
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
......@@ -243,6 +244,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_COPY: /* Copy */
GetScreen()->UpdatePickList();
// fall through
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->GetCount() )
{
......@@ -297,7 +299,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_FLIP: /* pcbnew only! */
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true;
break;
......@@ -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();
DrawPanel->Refresh();
}
if( ! nextcmd )
......@@ -327,7 +329,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if( zoom_command )
Window_Zoom( GetScreen()->m_BlockLocate );
return nextcmd ;
return nextcmd;
}
......
......@@ -365,7 +365,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
{
case SCH_JUNCTION_T:
case SCH_LINE_T:
DrawPanel->PostDirtyRect( item->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( item->GetBoundingBox() );
break;
default:
......
......@@ -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. */
#if 0
#ifdef USE_WX_ZOOM
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,
aOffset.y + len, 0, aColor );
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 )
int hotkey = 0;
double scalar = screen->GetScalingFactor();
ActiveScreen = screen;
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
......@@ -339,8 +337,6 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
int hotkey = 0;
double scalar = screen->GetScalingFactor();
ActiveScreen = screen;
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
......@@ -434,8 +430,6 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
int hotkey = 0;
double scalar = screen->GetScalingFactor();
ActiveScreen = screen;
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
......
......@@ -25,7 +25,6 @@
// Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
extern BASE_SCREEN* ActiveScreen;
#define WIDTH_MAX_VALUE 100
#define WIDTH_MIN_VALUE 1
......@@ -125,7 +124,6 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
schscreen = schframe->m_CurrentSheet->LastScreen();
ActiveScreen = schscreen;
}
else // Should not happen
return;
......@@ -169,8 +167,6 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
msg += wxT( "\n" );
m_MessagesBox->AppendText( msg );
}
ActiveScreen = oldscreen;
}
......
......@@ -820,8 +820,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
if( m_Cmp->m_Flags == 0 )
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 );
// Initialize field values to default values found in library:
......
......@@ -197,7 +197,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
if( m_CurrentText->m_Flags == 0 )
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();
if( !text.IsEmpty() )
......@@ -235,7 +235,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
if( (m_CurrentText->m_Flags & IS_NEW) != 0 )
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();
EndModal( wxID_OK );
}
......@@ -172,12 +172,11 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
{
sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() );
*m_Parent->m_CurrentSheet = *sheet;
ActiveScreen = m_Parent->m_CurrentSheet->LastScreen();
m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
}
sheet->LastScreen()->m_Curseur = pos;
m_Parent->Recadre_Trace( true );
m_Parent->RedrawScreen( true );
}
......
......@@ -145,7 +145,6 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
{
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent;
SCH_SCREEN* screen = schframe->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet();
wxString PlotFileName;
Ki_PageDescr* PlotSheet;
......@@ -168,27 +167,29 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
{
if( sheetpath == NULL )
break;
list.Clear();
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
schframe->m_CurrentSheet = &list;
schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
screen = schframe->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
}
else // Should not happen
return;
sheetpath = SheetList.GetNext();
}
PlotSheet = screen->m_CurrentSheetDesc;
double scale = 10;
plot_offset.x = 0;
plot_offset.y = 0;
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(
".dxf" );
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
PlotOneSheetDXF( PlotFileName, screen, PlotSheet, plot_offset, scale );
......@@ -196,7 +197,6 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
break;
}
ActiveScreen = oldscreen;
schframe->m_CurrentSheet = oldsheetpath;
schframe->m_CurrentSheet->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
......@@ -204,10 +204,10 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
SCH_SCREEN* screen,
Ki_PageDescr* sheet,
wxPoint plot_offset,
double scale )
SCH_SCREEN* screen,
Ki_PageDescr* sheet,
wxPoint plot_offset,
double scale )
{
wxString msg;
......
......@@ -208,6 +208,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( )
EESCHEMA_INTERNAL_UNIT);
if( 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 )
g_HPGL_Pen_Descr.m_Pen_Diam = 1;
}
......@@ -216,8 +217,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( )
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenSpeed( )
{
g_HPGL_Pen_Descr.m_Pen_Speed = m_penSpeedCtrl->GetValue();
if( 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 )
g_HPGL_Pen_Descr.m_Pen_Speed = 1;
}
......@@ -226,8 +229,10 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenSpeed( )
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenNum( )
{
g_HPGL_Pen_Descr.m_Pen_Num = m_penNumCtrl->GetValue();
if( 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 )
g_HPGL_Pen_Descr.m_Pen_Num = 1;
}
......@@ -258,8 +263,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll )
* selected sheet
*/
void DIALOG_PLOT_SCHEMATIC_HPGL::ReturnSheetDims( BASE_SCREEN* screen,
wxSize& SheetSize,
wxPoint& SheetOffset )
wxSize& SheetSize,
wxPoint& SheetOffset )
{
Ki_PageDescr* PlotSheet;
......@@ -277,7 +282,6 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
{
wxString PlotFileName;
SCH_SCREEN* screen = m_Parent->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* sheetpath, * oldsheetpath = m_Parent->GetSheet();
Ki_PageDescr* PlotSheet;
wxSize SheetSize;
......@@ -300,46 +304,47 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll, int HPGL_Sh
{
if( sheetpath == NULL )
break;
list.Clear();
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
m_Parent->m_CurrentSheet = &list;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount();
screen = m_Parent->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
}
else // Should not happen
return;
sheetpath = SheetList.GetNext();
}
ReturnSheetDims( screen, SheetSize, SheetOffset );
/* Calculation of conversion scales. */
if( HPGL_SheetSize )
PlotSheet = Plot_sheet_list[HPGL_SheetSize];
else
PlotSheet = screen->m_CurrentSheetDesc;
/* 10x because eeschema works in mils, not decimals */
double plot_scale = 10 * (double) PlotSheet->m_Size.x /
(double) SheetSize.x;
double plot_scale = 10 * (double) PlotSheet->m_Size.x / (double) SheetSize.x;
/* Calculate offsets */
PlotOffset.x = -SheetOffset.x;
PlotOffset.y = -SheetOffset.y;
PlotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() +
wxT( ".plt" );
PlotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
SetLocaleTo_C_standard();
Plot_1_Page_HPGL( PlotFileName, screen, PlotSheet, PlotOffset,
plot_scale );
Plot_1_Page_HPGL( PlotFileName, screen, PlotSheet, PlotOffset, plot_scale );
SetLocaleTo_Default();
if( !aPlotAll )
break;
}
ActiveScreen = oldscreen;
m_Parent->m_CurrentSheet = oldsheetpath;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount();
......@@ -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,
SCH_SCREEN* screen,
Ki_PageDescr* sheet,
wxPoint& offset,
double plot_scale )
SCH_SCREEN* screen,
Ki_PageDescr* sheet,
wxPoint& offset,
double plot_scale )
{
wxString msg;
......@@ -383,6 +388,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
plotter->start_plot( output_file );
plotter->set_color( BLACK );
if( m_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen );
......
......@@ -173,7 +173,6 @@ void DIALOG_PLOT_SCHEMATIC_PS::initOptVars()
void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
{
SCH_SCREEN* screen = m_Parent->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH* oldsheetpath = m_Parent->GetSheet(); // sheetpath is saved here
wxString plotFileName;
......@@ -198,20 +197,24 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
{
if( sheetpath == NULL )
break;
list.Clear();
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
m_Parent->m_CurrentSheet = &list;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount();
screen = m_Parent->m_CurrentSheet->LastScreen();
ActiveScreen = screen;
}
else // Should not happen
return;
sheetpath = SheetList.GetNext();
}
actualPage = screen->m_CurrentSheetDesc;
switch( m_pageSizeSelect )
{
case PAGE_SIZE_A:
......@@ -243,7 +246,6 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
break;
}
ActiveScreen = oldscreen;
m_Parent->m_CurrentSheet = oldsheetpath;
m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
m_Parent->SetSheetNumberAndCount();
......
......@@ -40,7 +40,7 @@ public:
bool HasPage( int page );
bool OnBeginDocument( int startPage, int endPage );
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 )
parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
SCH_SCREEN* screen = parent->GetScreen();
SCH_SCREEN* oldscreen = screen;
SCH_SHEET_PATH* oldsheetpath = parent->GetSheet();
SCH_SHEET_PATH list;
SCH_SHEET_LIST SheetList( NULL );
......@@ -248,9 +247,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page )
if( screen == NULL )
return false;
ActiveScreen = screen;
DrawPage();
ActiveScreen = oldscreen;
DrawPage( screen );
parent->m_CurrentSheet = oldsheetpath;
parent->m_CurrentSheet->UpdateAllScreenReferences();
parent->SetSheetNumberAndCount();
......@@ -259,8 +256,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page )
}
void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage,
int* selPageFrom, int* selPageTo )
void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo )
{
*minPage = *selPageFrom = 1;
*maxPage = *selPageTo = g_RootSheet->CountSheets();
......@@ -306,7 +302,7 @@ bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage )
/*
* This is the real print function: print the active screen
*/
void SCH_PRINTOUT::DrawPage()
void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
{
int oldZoom;
wxPoint tmp_startvisu;
......@@ -321,15 +317,12 @@ void SCH_PRINTOUT::DrawPage()
wxBusyCursor dummy;
/* Save current scale factor, offsets, and clip box. */
tmp_startvisu = ActiveScreen->m_StartVisu;
oldZoom = ActiveScreen->GetZoom();
old_org = ActiveScreen->m_DrawOrg;
tmp_startvisu = aScreen->m_StartVisu;
oldZoom = aScreen->GetZoom();
old_org = aScreen->m_DrawOrg;
oldClipBox = panel->m_ClipBox;
/* 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.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
......@@ -343,8 +336,9 @@ void SCH_PRINTOUT::DrawPage()
wxBitmap psuedoBitmap( 1, 1 );
wxMemoryDC memDC;
memDC.SelectObject( psuedoBitmap );
( (SCH_SCREEN*) ActiveScreen )->Draw( panel, &memDC, GR_DEFAULT_DRAWMODE );
parent->TraceWorkSheet( &memDC, ActiveScreen, g_DrawDefaultLineThickness );
aScreen->Draw( panel, &memDC, GR_DEFAULT_DRAWMODE );
parent->TraceWorkSheet( &memDC, aScreen, g_DrawDefaultLineThickness );
wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ),
memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() );
......@@ -356,7 +350,7 @@ void SCH_PRINTOUT::DrawPage()
}
else
{
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size;
SheetSize = aScreen->m_CurrentSheetDesc->m_Size;
FitThisSizeToPaper( SheetSize );
fitRect = GetLogicalPaperRect();
}
......@@ -369,21 +363,22 @@ void SCH_PRINTOUT::DrawPage()
if( parent->GetPrintMonochrome() )
GRForceBlackPen( true );
ActiveScreen->m_IsPrinting = true;
aScreen->m_IsPrinting = true;
int bg_color = g_DrawBgColor;
( ( SCH_SCREEN* ) ActiveScreen )->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference )
parent->TraceWorkSheet( dc, ActiveScreen, g_DrawDefaultLineThickness );
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness );
g_DrawBgColor = bg_color;
ActiveScreen->m_IsPrinting = false;
aScreen->m_IsPrinting = false;
panel->m_ClipBox = oldClipBox;
GRForceBlackPen( false );
ActiveScreen->m_StartVisu = tmp_startvisu;
ActiveScreen->m_DrawOrg = old_org;
ActiveScreen->SetZoom( oldZoom );
aScreen->m_StartVisu = tmp_startvisu;
aScreen->m_DrawOrg = old_org;
aScreen->SetZoom( oldZoom );
}
......@@ -50,8 +50,6 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( GetScreen() == NULL )
return;
ActiveScreen = GetScreen();
DrawPanel->DrawBackGround( DC );
GetScreen()->Draw( DrawPanel, DC, GR_DEFAULT_DRAWMODE );
......
......@@ -159,7 +159,6 @@ bool WinEDA_App::OnInit()
SetupServerFunction( RemoteCommand );
}
ActiveScreen = frame->GetScreen();
frame->Zoom_Automatique( TRUE );
/* Load file specified in the command line. */
......
......@@ -27,7 +27,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
if( !curr_item || curr_item->m_Flags )
return;
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( curr_item->Type() )
{
......
......@@ -61,13 +61,12 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
{
sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheetFoundIn;
ActiveScreen = m_CurrentSheet->LastScreen();
m_CurrentSheet->UpdateAllScreenReferences();
}
sheetFoundIn->LastScreen()->m_Curseur = lastMarker->m_Pos;
Recadre_Trace( TRUE );
RedrawScreen( TRUE );
wxString path = sheetFoundIn->Path();
wxString units = GetAbbreviatedUnitsLabel();
......@@ -184,7 +183,6 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
{
sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheet;
ActiveScreen = m_CurrentSheet->LastScreen();
m_CurrentSheet->UpdateAllScreenReferences();
DoCenterAndRedraw = TRUE;
}
......@@ -215,10 +213,10 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
#undef MARGIN
if( DoCenterAndRedraw )
Recadre_Trace( mouseWarp );
RedrawScreen( mouseWarp );
else
{
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
DrawPanel->CursorOff( &dc );
......@@ -329,13 +327,12 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event )
{
sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheetFoundIn;
ActiveScreen = m_CurrentSheet->LastScreen();
m_CurrentSheet->UpdateAllScreenReferences();
}
// sheetFoundIn->LastScreen()->m_Curseur = lastItem->GetBoundingBox().Centre();
sheetFoundIn->LastScreen()->m_Curseur = lastItemPosition;
Recadre_Trace( true );
RedrawScreen( true );
msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable();
SetStatusText( msg );
......
......@@ -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 );
else
{
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( DrawComponent->GetBoundingBox() );
}
}
......@@ -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
// 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.
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 );
......
......@@ -260,16 +260,14 @@ void SCH_EDIT_FRAME::InstallPreviousSheet()
ClearMsgPanel();
//make a copy for testing purposes.
SCH_SHEET_PATH listtemp = *m_CurrentSheet;
listtemp.Pop();
m_CurrentSheet->Pop();
if( listtemp.LastScreen() == NULL )
if( m_CurrentSheet->LastScreen() == NULL )
{
DisplayError( this, wxT( "InstallPreviousScreen() Error: Sheet not found" ) );
return;
}
m_CurrentSheet->Pop();
UpdateScreenFromSheet( this );
}
......@@ -286,6 +284,7 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet )
{
DisplayError( this, wxT( "InstallNextScreen() error" ) ); return;
}
m_CurrentSheet->Push( Sheet );
m_itemToRepeat = NULL;
ClearMsgPanel();
......@@ -298,41 +297,33 @@ void SCH_EDIT_FRAME::InstallNextScreen( SCH_SHEET* Sheet )
*/
static bool UpdateScreenFromSheet( SCH_EDIT_FRAME* frame )
{
SCH_SCREEN* NewScreen;
NewScreen = frame->m_CurrentSheet->LastScreen();
if( !NewScreen )
if( !frame->m_CurrentSheet->LastScreen() )
{
DisplayError( frame, wxT( "Screen not found for this sheet" ) );
return false;
}
SCH_SCREEN* screen = frame->m_CurrentSheet->LastScreen();
// Reset display settings of the new screen
// Assumes m_CurrentSheet has already been updated.
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
frame->m_CurrentSheet->UpdateAllScreenReferences();
frame->SetSheetNumberAndCount();
frame->DrawPanel->m_CanStartBlock = -1;
ActiveScreen = frame->m_CurrentSheet->LastScreen();
if( NewScreen->m_FirstRedraw )
if( screen->m_FirstRedraw )
{
NewScreen->m_FirstRedraw = FALSE;
frame->Zoom_Automatique( TRUE );
screen->m_FirstRedraw = false;
frame->Zoom_Automatique( true );
}
else
{
frame->DrawPanel->MouseToCursorSchema();
frame->RedrawScreen( true );
}
frame->DrawPanel->Refresh();
return true;
}
......@@ -198,8 +198,6 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( GetScreen() == NULL )
return;
ActiveScreen = GetScreen();
DrawPanel->DrawBackGround( DC );
if( m_component )
......
......@@ -640,7 +640,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id )
{
......@@ -928,6 +928,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( m_ID_current_state == 0 )
m_lastDrawItem = NULL;
}
......@@ -1072,7 +1073,7 @@ void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
wxCHECK_RET( m_component != NULL,
wxT( "Cannot create new part from non-existant current part." ) );
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
DrawPanel->CursorOff( &dc );
EditField( &dc, &m_component->GetValueField() );
DrawPanel->MouseToCursorSchema();
......
......@@ -167,7 +167,7 @@ void DeleteStruct( EDA_DRAW_PANEL* panel, wxDC* DC, SCH_ITEM* DrawStruct )
{
screen->RemoveFromDrawList( DrawStruct );
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
panel->RefreshDrawingRect( DrawStruct->GetBoundingBox() );
/* Unlink the structure */
DrawStruct->SetNext( 0 );
......
......@@ -531,6 +531,6 @@ private:
};
typedef boost::ptr_vector< SCH_SHEET > SCH_SHEETS;
typedef std::vector< SCH_SHEET* > SCH_SHEETS;
#endif /* CLASS_DRAWSHEET_H */
......@@ -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;
unsigned i;
for( i = 0; i < m_numSheets; i++ )
{
m_sheets[i] = d1.m_sheets[i];
}
for( ; i < DSLSZ; i++ )
{
m_sheets[i] = 0;
}
return true;
return *this;
}
......@@ -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 */
/*********************************************************************/
......@@ -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()
{
int ref = 1;
......
......@@ -240,11 +240,11 @@ public:
SCH_ITEM* MatchNextItem( wxFindReplaceData& aSearchData, SCH_ITEM* aLastItem,
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 { return !( *this == d1 ) ; }
};
......@@ -336,6 +336,15 @@ public:
*/
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
* clear and annotates the entire hierarchy of the sheet path list.
......
......@@ -156,7 +156,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
}
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id )
{
case ID_HIERARCHY:
......@@ -403,7 +404,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SaveCopyInUndoList( sheet, UR_CHANGED );
sheet->CleanupSheet();
OnModify();
DrawPanel->PostDirtyRect( sheet->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
}
break;
......
......@@ -346,23 +346,12 @@ void SCH_EDIT_FRAME::CreateScreens()
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SCH_SHEET_PATH* sheet;
if( m_LibeditFrame ) // Can close component editor ?
{
if( !m_LibeditFrame->Close() )
return;
}
if( m_LibeditFrame && !m_LibeditFrame->Close() ) // Can close component editor?
return;
SCH_SHEET_LIST SheetList;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
{
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
break;
}
if( sheet )
if( SheetList.IsModified() )
{
wxMessageDialog dialog( this,
_( "Schematic modified, Save before exit ?" ),
......@@ -385,15 +374,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
}
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
{
if( sheet->LastScreen() )
{
sheet->LastScreen()->ClrModify();
}
}
SheetList.ClearModifyStatus();
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty()
&& (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
......@@ -733,7 +714,6 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
ActiveScreen = GetBaseScreen();
m_LibeditFrame->AdjustScrollBars();
}
}
......
......@@ -271,7 +271,7 @@ void SCH_EDIT_FRAME::DeleteSheetLabel( bool aRedraw, SCH_SHEET_PIN* aSheetLabelT
parent->RemoveLabel( aSheetLabelToDel );
if( aRedraw )
DrawPanel->PostDirtyRect( parent->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( parent->GetBoundingBox() );
#if 0 && defined(DEBUG)
......
......@@ -237,6 +237,6 @@ void LIB_EDIT_FRAME::PlaceAncre()
/* Redraw the symbol */
GetScreen()->m_Curseur.x = GetScreen()->m_Curseur.y = 0;
Recadre_Trace( TRUE );
RedrawScreen( TRUE );
DrawPanel->Refresh();
}
......@@ -259,8 +259,6 @@ void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
wxString msg;
wxString tmp;
ActiveScreen = GetScreen();
lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib == NULL )
......
......@@ -78,11 +78,10 @@ void WinEDA_GerberFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
wxBusyCursor dummy;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY );
int drawMode = -1;
switch ( GetDisplayMode() )
{
default:
......
......@@ -117,6 +117,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
}
INSTALL_DC( dc, DrawPanel );
switch( id )
{
case ID_EXIT:
......
......@@ -96,8 +96,6 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
wxFileName filename = aFullFileName;
wxString currentPath;
ActiveScreen = GetScreen();
if( ! filename.IsOk() )
{
/* Standard gerber filetypes
......@@ -197,14 +195,11 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
* 0 if file not read (cancellation of order ...)
* 1 if OK
*/
static void LoadDCodeFile( WinEDA_GerberFrame* frame,
const wxString& FullFileName )
static void LoadDCodeFile( WinEDA_GerberFrame* frame, const wxString& FullFileName )
{
wxString wildcard;
wxFileName fn = FullFileName;
ActiveScreen = frame->GetScreen();
if( !fn.IsOk() )
{
wildcard.Printf( _( "Gerber DCODE files (%s)|*.%s" ),
......
......@@ -152,7 +152,6 @@ END_EVENT_TABLE() WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father
#endif
SetBaseScreen( ScreenPcb );
ActiveScreen = ScreenPcb;
SetBoard( new BOARD( NULL, this ) );
GetBoard()->SetEnabledLayers( FULL_LAYERS ); // All 32 layers enabled at first.
......
......@@ -93,7 +93,6 @@ bool WinEDA_App::OnInit()
}
ScreenPcb = new PCB_SCREEN();
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
ActiveScreen = ScreenPcb;
// read current setup and reopen last directory if no filename to open in
// command line
......
......@@ -44,7 +44,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0;
SetBaseScreen( ActiveScreen = ScreenPcb );
SetBaseScreen( ScreenPcb );
GetScreen()->Init();
setActiveLayer(LAYER_N_BACK);
syncLayerBox();
......
......@@ -62,7 +62,6 @@ public:
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */
wxPoint m_Curseur; /* Screen cursor coordinate (on 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)
* in user units.
* (coordinates from last reset position)*/
......@@ -165,13 +164,6 @@ public:
wxSize ReturnPageSize( 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.
*
......@@ -301,16 +293,6 @@ public:
*/
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 SetPreviousZoom();
bool SetFirstZoom();
......
......@@ -89,7 +89,6 @@ public:
}
void OnPaint( wxPaintEvent& event );
void OnSize( wxSizeEvent& event );
/**
* Function DrawBackGround
......@@ -128,7 +127,7 @@ public:
*/
void DrawGridAxis( wxDC* aDC, int aDrawMode );
void OnEraseBackground( wxEraseEvent& event );
void OnEraseBackground( wxEraseEvent& event ) { }
void OnActivate( wxActivateEvent& event );
......@@ -141,7 +140,7 @@ public:
* update the boundary box. If wxDC coordinate manipulation is used, then
* 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
* connects everything together to acheive the appropiate coordinate
* connects everything together to achieve the appropriate coordinate
* manipulation using wxDC LogicalToDeviceXXX and DeviceToLogixalXXX
* methods. This gets called automatically for a paint event. If you do
* any drawing outside the paint event, you must call DoPrepareDC manually.
......@@ -150,6 +149,18 @@ public:
*/
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 */
void OnMouseWheel( wxMouseEvent& event );
void OnMouseEvent( wxMouseEvent& event );
......@@ -171,7 +182,22 @@ public:
void Process_Special_Functions( wxCommandEvent& event );
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 );
/**
......@@ -183,40 +209,18 @@ public:
/**
* 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();
/**
* Function PostDirtyRect
* appends the given rectangle in pcb units to the DrawPanel's invalid
* region list so that very soon (but not immediately), this rectangle
* along with any other recently posted rectangles is redrawn. Conversion
* to pixels is done in here.
* @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
* Function RefreshDrawingRect
* redraws the contents of \a aRect in drawing units. \a aRect is converted to
* screen coordinates and wxWindow::RefreshRect() is called to repaint the region.
* @param aRect The rectangle to repaint.
* @param aEraseBackground Erases the background if true.
*/
void ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition );
void RefreshDrawingRect( const EDA_Rect& aRect, bool aEraseBackground = true );
wxPoint GetScreenCenterRealPosition( void );
void MouseToCursorSchema();
......
......@@ -45,9 +45,6 @@ typedef enum {
} GRLineStypeType;
int GRMapX( int x );
int GRMapY( int y );
class EDA_DRAW_PANEL;
void GRSetDrawMode( wxDC* DC, int mode );
......@@ -68,8 +65,6 @@ void GRForceBlackPen( bool flagforce );
*/
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* 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,
......
/*
* 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
* @file kicad_device_context.h
......@@ -6,43 +32,89 @@
#ifndef __KICAD_DEVICE_CONTEXT_H__
#define __KICAD_DEVICE_CONTEXT_H__
// Comment this line to use the standard wxClientDC
// and uncomment to use buffered DC
// #define KICAD_USE_BUFFERED_DC // Currently under test
#include <wx/dcbuffer.h>
// Comment this line to use the standard wxPaintDC
// and uncomment to use buffered PaintDC
#define KICAD_USE_BUFFERED_PAINTDC // Currently under test
#if defined(KICAD_USE_BUFFERED_PAINTDC)
#undef KICAD_USE_BUFFERED_PAINTDC
#endif
#if defined KICAD_USE_BUFFERED_DC || defined KICAD_USE_BUFFERED_PAINTDC
#ifndef KICAD_USE_BUFFERED_PAINTDC
#define KICAD_USE_BUFFERED_PAINTDC
#endif
#include <wx/dcbuffer.h>
#if defined(KICAD_USE_BUFFERED_DC)
#undef KICAD_USE_BUFFERED_DC
#endif
// 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
#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>
#endif
// 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" )
#define INSTALL_DC(name,parent) \
#define INSTALL_DC( name, parent ) \
wxClientDC _cDC( parent ); \
wxGCDC name(_cDC); \
wxGCDC name( _cDC ); \
parent->DoPrepareDC( name ); \
name.GetGraphicsContext()->Translate( 0.5, 0.5 );
#else
#ifdef KICAD_USE_BUFFERED_DC
#if KICAD_USE_BUFFERED_DC && !KICAD_USE_BUFFERED_DC_HELPER
//#pragma message( "INSTALL_DC is wxClientDC with wxBufferedDC" )
#define INSTALL_DC(name,parent) \
#define INSTALL_DC( name, parent ) \
wxClientDC _cDC( parent ); \
wxBufferedDC name(&_cDC, _cDC.GetSize() ); \
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
//#pragma message( "INSTALL_DC is wxClientDC" )
#define INSTALL_DC(name,parent) \
#define INSTALL_DC( name, parent ) \
wxClientDC name( parent ); \
parent->DoPrepareDC( name );
#endif
......@@ -50,16 +122,22 @@
#if USE_WX_GRAPHICS_CONTEXT
//#pragma message( "INSTALL_PAINTDC is wxPaintDC with wxGCDC" )
#define INSTALL_PAINTDC(name,parent) \
wxPaintDC _pDC(parent); \
wxGCDC name(_pDC); \
#define INSTALL_PAINTDC( name, parent) \
wxPaintDC _pDC( parent ); \
wxGCDC name( _pDC ); \
parent->DoPrepareDC( name ); \
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" )
#define INSTALL_PAINTDC(name,parent) \
wxAutoBufferedPaintDC name(parent ); \
#define INSTALL_PAINTDC( name, parent ) \
wxAutoBufferedPaintDC name( parent ); \
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
//#pragma message( "INSTALL_PAINTDC is wxPaintDC" )
#define INSTALL_PAINTDC(name,parent) \
......@@ -67,4 +145,11 @@
parent->DoPrepareDC( name );
#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__
......@@ -372,7 +372,17 @@ public:
void SetToolbarBgColor( int color_num );
virtual void OnZoom( wxCommandEvent& event );
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
* @param aCoord = coordinate to adjust
......
......@@ -43,7 +43,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
if( m_HToolBar == NULL )
return;
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
switch( id )
{
......
......@@ -237,9 +237,9 @@ void DisplayBoard( EDA_DRAW_PANEL* panel, wxDC* DC )
{
for( i = 0; i < maxi; i++ )
for( j = 0; j < maxi; j++ )
GRSPutPixel( &panel->m_ClipBox, DC,
( col * maxi ) + i + DRAW_OFFSET_X,
( row * maxi ) + j + DRAW_OFFSET_Y, color );
GRPutPixel( &panel->m_ClipBox, DC,
( col * maxi ) + i + DRAW_OFFSET_X,
( row * maxi ) + j + DRAW_OFFSET_Y, color );
}
}
......
......@@ -135,7 +135,7 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos )
if( !DrawPanel->IsPointOnDisplay( aPos ) )
{
screen->m_Curseur = aPos;
Recadre_Trace( true );
RedrawScreen( true );
}
else
{
......
......@@ -550,11 +550,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxP
typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( width ) < 2 )
#else
if( panel->GetScreen()->Scale( width ) < 2 )
#endif
typeaff = FILAIRE;
switch( typeaff )
......
......@@ -258,11 +258,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
if( m_Flags & FORCE_SKETCH )
mode = SKETCH;
#ifdef USE_WX_ZOOM
if( l_piste < DC->DeviceToLogicalXRel( L_MIN_DESSIN ) )
#else
if( l_piste < panel->GetScreen()->Unscale( L_MIN_DESSIN ) )
#endif
mode = FILAIRE;
switch( m_Shape )
......
......@@ -190,11 +190,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wx
typeaff = SKETCH;
}
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( m_Width ) < L_MIN_DESSIN )
#else
if( screen->Scale( m_Width ) < L_MIN_DESSIN )
#endif
typeaff = FILAIRE;
switch( type_trace )
......
......@@ -118,11 +118,7 @@ void MIREPCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int mode_color, const wxPoi
typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width;
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( width ) < 2 )
#else
if( panel->GetScreen()->Scale( width ) < 2 )
#endif
typeaff = FILAIRE;
rayon = m_Size / 4;
......
......@@ -67,11 +67,7 @@ MODULE::~MODULE()
void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode )
{
#ifdef USE_WX_ZOOM
int anchor_size = DC->DeviceToLogicalXRel( dim_ancre );
#else
int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
#endif
GRSetDrawMode( DC, draw_mode );
......
......@@ -42,9 +42,7 @@ public:
bool m_ShowNCMark; // true to show pad not connected mark
bool m_IsPrinting; // true to print, false to display on screen.
wxPoint m_Offset; // general draw offset
#ifndef USE_WX_ZOOM
double m_Scale; // Draw scaling factor
#endif
PAD_DRAWINFO( );
};
......
......@@ -37,9 +37,6 @@ PAD_DRAWINFO::PAD_DRAWINFO()
m_Display_netname = true;
m_ShowPadFilled = true;
m_ShowNCMark = true;
#ifndef USE_WX_ZOOM
m_Scale = 1.0;
#endif
m_IsPrinting = false;
}
......@@ -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_ShowNCMark = brd->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) );
drawInfo.m_IsPrinting = screen->m_IsPrinting;
#ifndef USE_WX_ZOOM
drawInfo.m_Scale = (double) screen->Scale( 1000 ) / 1000;
#endif
SetAlpha( &color, 170 );
/* 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 )
{
case PAD_CIRCLE:
#ifdef USE_WX_ZOOM
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,
aDrawInfo.m_Color, aDrawInfo.m_HoleColor );
break;
......@@ -579,11 +569,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#define CHAR_SIZE_MIN 5
#ifdef USE_WX_ZOOM
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
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
{
// tsize reserve room for marges and segments thickness
tsize = (int) ( tsize * 0.8 );
......@@ -600,11 +586,7 @@ void D_PAD::DrawShape( EDA_Rect* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT );
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.
#else
if( aDrawInfo.m_Scale * tsize >= CHAR_SIZE_MIN ) // Not drawable in size too small.
#endif
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
{
tpos = tpos0;
if( aDrawInfo.m_Display_padnum )
......
......@@ -354,12 +354,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w
width = m_Thickness;
if( ( frame->m_DisplayModText == FILAIRE )
#ifdef USE_WX_ZOOM
|| ( DC->LogicalToDeviceXRel( width ) < L_MIN_DESSIN ) )
#else
|| ( screen->Scale( width ) < L_MIN_DESSIN ) )
#endif
|| ( DC->LogicalToDeviceXRel( width ) < L_MIN_DESSIN ) )
width = 0;
else if( frame->m_DisplayModText == SKETCH )
width = -width;
......@@ -371,11 +366,8 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const w
{
color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
#ifdef USE_WX_ZOOM
int anchor_size = DC->DeviceToLogicalXRel( 2 );
#else
int anchor_size = screen->Unscale( 2 );
#endif
GRLine( &panel->m_ClipBox, DC,
pos.x - anchor_size, pos.y,
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&
rayon = (int) hypot( (double) ( m_End.x - m_Start.x ),
(double) ( m_End.y - m_Start.y ) );
#ifdef USE_WX_ZOOM
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,
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&
else
{
#ifdef USE_WX_ZOOM
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,
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&
return;
}
#ifdef USE_WX_ZOOM
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,
m_Start.y + aOffset.y,
......@@ -695,11 +683,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint&
if( len < THRESHOLD * m_Width )
return;
#ifdef USE_WX_ZOOM
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;
if( GetNet() == 0 )
......@@ -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
angle = 900; // angle is in 0.1 degree
#ifdef USE_WX_ZOOM
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
#else
if( panel->GetScreen()->Scale( tsize ) >= 6 )
#endif
{
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) )
{
......@@ -791,22 +771,14 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
rayon = m_Width >> 1;
// for small via size on screen (rayon < 4 pixels) draw a simplified shape
#ifdef USE_WX_ZOOM
int radius_in_pixels = DC->LogicalToDeviceXRel( rayon );
#else
int radius_in_pixels = panel->GetScreen()->Scale( rayon );
#endif
bool fast_draw = false;
// Vias are drawn as a filled circle or a double circle. The hole will be drawn later
int drill_rayon = GetDrillValue() / 2;
#ifdef USE_WX_ZOOM
int inner_rayon = rayon - DC->DeviceToLogicalXRel( 2 );
#else
int inner_rayon = rayon - panel->GetScreen()->Unscale( 2 );
#endif
if( radius_in_pixels < 3 )
{
......@@ -852,11 +824,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint
else
GRSetDrawMode( DC, GR_XOR );
#ifdef USE_WX_ZOOM
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
if( DC->LogicalToDeviceXRel( drill_rayon ) > 1 ) // Draw hole if large enough.
GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
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
// calculate a good size for the text
int tsize = m_Width / len;
#ifdef USE_WX_ZOOM
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
DrawGraphicText( panel, DC, m_Start,
......
......@@ -344,7 +344,8 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
if( !Drc_On || !g_CurrentTrackSegment
|| 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;
}
......
......@@ -121,7 +121,7 @@ void RemoteCommand( const char* cmdline )
}
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 )
container->Remove( aTrack );
// redraw the area where the track was
DrawPanel->PostDirtyRect( aTrack->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( aTrack->GetBoundingBox() );
SaveCopyInUndoList( aTrack, UR_DELETED );
OnModify();
......@@ -163,7 +163,7 @@ void WinEDA_PcbFrame::Delete_net( wxDC* DC, TRACK* aTrack )
GetBoard()->m_Track.Remove( segm );
// redraw the area where the track was
DrawPanel->PostDirtyRect( segm->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( segm->GetBoundingBox() );
picker.m_PickedItem = segm;
picker.m_PickedItemType = segm->Type();
itemsList.PushItem( picker );
......@@ -214,7 +214,7 @@ void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
GetBoard()->m_Track.Remove( tracksegment );
// redraw the area where the track was
DrawPanel->PostDirtyRect( tracksegment->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( tracksegment->GetBoundingBox() );
picker.m_PickedItem = tracksegment;
picker.m_PickedItemType = tracksegment->Type();
itemsList.PushItem( picker );
......
......@@ -259,9 +259,9 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
int bg_color = g_DrawBgColor;
g_DrawBgColor = WHITE;
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);
g_DrawBgColor = bg_color;
......
......@@ -133,26 +133,8 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
scale *= 0.7;
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 );
#ifndef USE_WX_ZOOM
ActiveScreen->m_DrawOrg = org;
ActiveScreen->m_StartVisu = strt;
ActiveScreen->SetZoom( pzoom );
#endif
event.Skip();
}
......@@ -582,7 +564,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
// redraw the area where the pad was, without pad (delete pad on screen)
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;
// Update values
......@@ -651,7 +633,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_CurrentPad->DisplayInfo( m_Parent );
// redraw the area where the pad was
m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() );
m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() );
m_Parent->OnModify();
}
......
......@@ -35,7 +35,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos;
int itmp;
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
BOARD_ITEM* DrawStruct = GetCurItem();
MODULE* module;
......
......@@ -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 width = aTrack->m_Width;
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
wxPoint ref = ActiveScreen->RefPos( true );
TRACK* found = NULL;
......@@ -565,17 +562,16 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
if( track->GetState( BUSY | DELETED ) )
continue;
if( layer != track->GetLayer() )
if( aLayer != track->GetLayer() )
continue;
if( track->GetNet() == net )
continue;
/* TRACK::HitTest */
int dist = (width + track->m_Width) / 2 + aTrack->GetClearance(
track );
int dist = (width + track->m_Width) / 2 + aTrack->GetClearance( track );
wxPoint pos = ref - track->m_Start;
wxPoint pos = aRef - track->m_Start;
wxPoint vec = track->m_End - track->m_Start;
if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) )
......@@ -585,8 +581,8 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
/* prefer intrusions from the side, not the end */
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;
}
}
......@@ -613,8 +609,9 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
*/
static void PushTrack( EDA_DRAW_PANEL* panel )
{
PCB_SCREEN* screen = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetScreen();
BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard();
wxPoint cursor = ActiveScreen->m_Curseur;
wxPoint cursor = screen->m_Curseur;
wxPoint cv, vec, n;
TRACK* track = g_CurrentTrackSegment;
TRACK* other;
......@@ -622,7 +619,7 @@ static void PushTrack( EDA_DRAW_PANEL* panel )
int dist;
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 ? */
if( !other )
......@@ -740,7 +737,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase )
{
if( g_TwoSegmentTrackBuild )
{
g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur;
g_CurrentTrackSegment->m_End = screen->m_Curseur;
if( Drc_On )
PushTrack( panel );
......
......@@ -110,7 +110,7 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )
if( Text->m_Type == TEXT_is_DIVERS )
{
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
Text->DeleteStructure();
OnModify();
Module->m_LastEdit_Time = time( NULL );
......@@ -146,7 +146,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
Text->m_Orient = TextInitialOrientation;
/* 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.
MoveVector.x = MoveVector.y = 0;
......@@ -200,7 +200,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{
if( Text != NULL )
{
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
Text->DrawUmbilical( DrawPanel, DC, GR_XOR, -MoveVector );
/* Update the coordinates for anchor. */
......@@ -226,7 +226,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
OnModify();
/* Redraw text. */
DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Text->GetBoundingBox() );
}
else
Text->m_Pos = GetScreen()->m_Curseur;
......
......@@ -199,7 +199,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( aDraw )
{
Module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
Module->m_Flags &= ~DO_NOT_DRAW;
}
......@@ -273,7 +273,7 @@ void WinEDA_BasePcbFrame::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
Module->Set_Rectangle_Encadrement();
if( aDraw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
}
OnModify();
......
......@@ -164,7 +164,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos;
bool redraw = false;
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
wxGetMousePosition( &pos.x, &pos.y );
......
......@@ -138,7 +138,7 @@ m_Flags != 0\nStruct @%p, type %d m_Flag %X" ),
Place_Ancre( module ); // set the new relatives internal
// coordinates of items
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Recadre_Trace( TRUE );
RedrawScreen( TRUE );
// Replace the module in position 0, to recalculate absolutes
// coordinates of items
......
......@@ -104,7 +104,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
{
int tmp = module->m_Flags;
module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( module->GetBoundingBox() );
module->m_Flags = tmp;
}
......@@ -328,7 +328,7 @@ void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
{
int tmp = Module->m_Flags;
Module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
Module->m_Flags = tmp;
}
......@@ -482,7 +482,7 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
{
int tmp = module->m_Flags;
module->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( module->GetBoundingBox() );
module->m_Flags = tmp;
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
......
......@@ -128,7 +128,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( aDraw )
{
aPad->m_Flags |= DO_NOT_DRAW;
DrawPanel->PostDirtyRect( aPad->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( aPad->GetBoundingBox() );
aPad->m_Flags &= ~DO_NOT_DRAW;
}
......@@ -166,7 +166,7 @@ void WinEDA_BasePcbFrame::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
aPad->ComputeShapeMaxRadius();
if( aDraw )
DrawPanel->PostDirtyRect( aPad->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( aPad->GetBoundingBox() );
( (MODULE*) aPad->GetParent() )->m_LastEdit_Time = time( NULL );
}
......@@ -220,7 +220,7 @@ void WinEDA_BasePcbFrame::AddPad( MODULE* Module, bool draw )
Module->Set_Rectangle_Encadrement();
Pad->DisplayInfo( this );
if( draw )
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
}
......@@ -254,7 +254,7 @@ void WinEDA_BasePcbFrame::DeletePad( D_PAD* aPad, bool aQuery )
m_Pcb->m_Status_Pcb = 0;
aPad->DeleteStructure();
DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
Module->Set_Rectangle_Encadrement();
OnModify();
......
......@@ -21,7 +21,7 @@ void WinEDA_PcbFrame::ProcessMuWaveFunctions( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
wxGetMousePosition( &pos.x, &pos.y );
......
......@@ -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
* (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 */
#ifdef USE_WX_ZOOM
int y_dc_offset = PlotAreaSizeInPixels.y;
y_dc_offset = (int) ( ( double ) y_dc_offset * userscale );
dc->SetDeviceOrigin( 0, y_dc_offset );
#endif
int ysize = (int) ( PlotAreaSizeInPixels.y / scaley );
DrawOffset.y += ysize;
......@@ -277,13 +275,11 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
* to the middle of the page.
*/
wxPoint pcb_centre = brd_BBox.Centre();
if( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize / 2);
#ifdef USE_WX_ZOOM
dc->SetLogicalOrigin( ActiveScreen->m_DrawOrg.x, ActiveScreen->m_DrawOrg.y );
#else
ActiveScreen->m_DrawOrg = DrawOffset;
#endif
dc->SetLogicalOrigin( ActiveScreen->m_DrawOrg.x, ActiveScreen->m_DrawOrg.y );
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 );
/* 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 );
......
......@@ -78,7 +78,7 @@ void WinEDA_PcbFrame::ListNetsAndSelect( wxCommandEvent& event )
if( found )
{
INSTALL_DC( dc, DrawPanel );
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
if( g_HighLight_Status )
High_Light( &dc );
......
......@@ -329,7 +329,7 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_contain
if( zone_container->m_Poly->GetNumCorners() <= 3 )
{
DrawPanel->PostDirtyRect( zone_container->GetBoundingBox() );
DrawPanel->RefreshDrawingRect( zone_container->GetBoundingBox() );
if( DC )
{ // Remove the full zone because this is no more an area
Delete_Zone_Fill( NULL, zone_container->m_TimeStamp );
......@@ -864,7 +864,7 @@ void WinEDA_PcbFrame::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_contai
zone_container->m_Poly->RemoveContour( ncont );
}
DrawPanel->PostDirtyRect( dirty );
DrawPanel->RefreshDrawingRect( dirty );
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