Commit aab2f8a7 authored by stambaughw's avatar stambaughw

USE_WX_ZOOM clean up and other minor improvements.

* Make USE_WX_ZOOM clipping routine actually clip rather than just test
  if line needs drawn.
* Clean up as many USE_WX_ZOOM #ifdefs as possible.
* Minor coordinate rounding improvements.
* Minor scrolling and panning improvements.
* Remove unused KicadGraphicContext object code.
parent 1da3a164
...@@ -22,6 +22,12 @@ ...@@ -22,6 +22,12 @@
#include <wx/fontdlg.h> #include <wx/fontdlg.h>
/* Definitions for enabling and disabling extra debugging output. Please
* remember to set these to 0 before committing changes to SVN.
*/
#define DEBUG_DUMP_SCROLLBAR_SETTINGS 0 // Set to 1 to print scroll bar settings.
/* Configuration entry names. */ /* Configuration entry names. */
static const wxString CursorShapeEntryKeyword( wxT( "CursorShape" ) ); static const wxString CursorShapeEntryKeyword( wxT( "CursorShape" ) );
static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) ); static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) );
...@@ -446,6 +452,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -446,6 +452,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
int unitsX, unitsY, posX, posY; int unitsX, unitsY, posX, posY;
wxSize drawingSize, clientSize; wxSize drawingSize, clientSize;
BASE_SCREEN* screen = GetBaseScreen(); BASE_SCREEN* screen = GetBaseScreen();
bool noRefresh = true;
if( screen == NULL || DrawPanel == NULL ) if( screen == NULL || DrawPanel == NULL )
return; return;
...@@ -457,30 +464,27 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -457,30 +464,27 @@ void WinEDA_DrawFrame::AdjustScrollBars()
// client area at the current zoom level. // client area at the current zoom level.
clientSize = DrawPanel->GetClientSize(); clientSize = DrawPanel->GetClientSize();
#ifdef USE_WX_ZOOM double scalar = screen->GetScalingFactor();
INSTALL_DC( dc, DrawPanel ); clientSize.x = wxRound( (double) clientSize.x / scalar );
clientSize.x = dc.DeviceToLogicalXRel( clientSize.x ); clientSize.y = wxRound( (double) clientSize.y / scalar );
clientSize.y = dc.DeviceToLogicalYRel( clientSize.y );
#else
screen->Unscale( clientSize );
#endif
/* Adjust drawing size when zooming way out to prevent centering around /* Adjust drawing size when zooming way out to prevent centering around
* cursor problems. */ * cursor problems. */
if( clientSize.x > drawingSize.x || clientSize.y > drawingSize.y ) if( clientSize.x > drawingSize.x || clientSize.y > drawingSize.y )
drawingSize = clientSize; drawingSize = clientSize;
drawingSize += clientSize / 2; drawingSize.x += wxRound( (double) clientSize.x / 2.0 );
drawingSize.y += wxRound( (double) clientSize.y / 2.0 );
if( screen->m_Center ) if( screen->m_Center )
{ {
screen->m_DrawOrg.x = -drawingSize.x / 2; screen->m_DrawOrg.x = -wxRound( (double) drawingSize.x / 2.0 );
screen->m_DrawOrg.y = -drawingSize.y / 2; screen->m_DrawOrg.y = -wxRound( (double) drawingSize.y / 2.0 );
} }
else else
{ {
screen->m_DrawOrg.x = -clientSize.x / 2; screen->m_DrawOrg.x = -wxRound( (double) clientSize.x / 2.0 );
screen->m_DrawOrg.y = -clientSize.y / 2; screen->m_DrawOrg.y = -wxRound( (double) clientSize.y / 2.0 );
} }
/* Always set scrollbar pixels per unit to 1 unless you want the zoom /* Always set scrollbar pixels per unit to 1 unless you want the zoom
...@@ -492,41 +496,32 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -492,41 +496,32 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1; screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
// Calculate the number of scroll bar units for the given zoom level. */ // Calculate the number of scroll bar units for the given zoom level. */
#ifdef USE_WX_ZOOM unitsX = wxRound( (double) drawingSize.x * scalar );
unitsX = dc.LogicalToDeviceXRel( drawingSize.x ); unitsY = wxRound( (double) drawingSize.y * scalar );
unitsY = dc.LogicalToDeviceYRel( drawingSize.y );
#else
unitsX = screen->Scale( drawingSize.x );
unitsY = screen->Scale( drawingSize.y );
#endif
// Calculate the position, place the cursor at the center of screen. // Calculate the position, place the cursor at the center of screen.
posX = screen->m_Curseur.x - screen->m_DrawOrg.x; posX = screen->m_Curseur.x - screen->m_DrawOrg.x;
posY = screen->m_Curseur.y - screen->m_DrawOrg.y; posY = screen->m_Curseur.y - screen->m_DrawOrg.y;
posX -= clientSize.x / 2; posX -= wxRound( (double) clientSize.x / 2.0 );
posY -= clientSize.y / 2; posY -= wxRound( (double) clientSize.y / 2.0 );
if( posX <= 0 ) if( posX < 0 )
posX = 0; posX = 0;
if( posY <= 0 ) if( posY < 0 )
posY = 0; posY = 0;
#ifdef USE_WX_ZOOM posX = wxRound( (double) posX * scalar );
posX = dc.LogicalToDeviceXRel( posX ); posY = wxRound( (double) posY * scalar );
posY = dc.LogicalToDeviceYRel( posY );
#else
posX = screen->Scale( posX );
posY = screen->Scale( posY );
#endif
screen->m_ScrollbarPos = wxPoint( posX, posY ); screen->m_ScrollbarPos = wxPoint( posX, posY );
screen->m_ScrollbarNumber = wxSize( unitsX, unitsY ); screen->m_ScrollbarNumber = wxSize( unitsX, unitsY );
#if 0 #if DEBUG_DUMP_SCROLLBAR_SETTINGS
wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ), wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
m_ScrollPixelsPerUnitX, m_ScrollPixelsPerUnitY, screen->m_ScrollPixelsPerUnitX, screen->m_ScrollPixelsPerUnitY,
unitsX, unitsY, posX, posY ); screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
#endif #endif
DrawPanel->SetScrollbars( screen->m_ScrollPixelsPerUnitX, DrawPanel->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
...@@ -534,7 +529,7 @@ void WinEDA_DrawFrame::AdjustScrollBars() ...@@ -534,7 +529,7 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.x,
screen->m_ScrollbarNumber.y, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.x,
screen->m_ScrollbarPos.y, TRUE ); screen->m_ScrollbarPos.y, noRefresh );
} }
......
This diff is collapsed.
...@@ -38,6 +38,13 @@ ...@@ -38,6 +38,13 @@
*/ */
/* Definitions for enabling and disabling debugging features in gr_basic.cpp.
* Please remember to set these back to 0 before making SVN commits.
*/
#define DEBUG_DUMP_CLIP_ERROR_COORDS 0 // Set to 1 to dump clip algorithm errors.
#define DEBUG_DUMP_CLIP_COORDS 0 // Set to 1 to dump clipped coordinates.
// For draw mode = XOR GR_XOR or GR_NXOR by background color // For draw mode = XOR GR_XOR or GR_NXOR by background color
int g_XorMode = GR_NXOR; int g_XorMode = GR_NXOR;
...@@ -138,8 +145,6 @@ int GRMapY( int y ) ...@@ -138,8 +145,6 @@ int GRMapY( int y )
#define WHEN_INSIDE #define WHEN_INSIDE
#if defined( USE_WX_ZOOM )
/** /**
* Test if any part of a line falls within the bounds of a rectangle. * Test if any part of a line falls within the bounds of a rectangle.
* *
...@@ -153,56 +158,224 @@ int GRMapY( int y ) ...@@ -153,56 +158,224 @@ int GRMapY( int y )
* *
* @return - False if any part of the line lies within the rectangle. * @return - False if any part of the line lies within the rectangle.
*/ */
static bool clipLine( EDA_Rect* aClipBox, int x1, int y1, int x2, int y2 ) static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
{ {
if( aClipBox->Inside( x1, y1 ) || aClipBox->Inside( x2, y2 ) ) if( aClipBox->Inside( x1, y1 ) && aClipBox->Inside( x2, y2 ) )
return false; return false;
int ax1, ay1, ax2, ay2; wxRect rect = *aClipBox;
wxRect rect =*aClipBox; int minX = rect.GetLeft();
ax1 = rect.GetBottomLeft().x; int maxX = rect.GetRight();
ay1 = rect.GetBottomLeft().y; int minY = rect.GetTop();
ax2 = rect.GetTopLeft().x; int maxY = rect.GetBottom();
ay2 = rect.GetTopLeft().y; int clippedX, clippedY;
#if DEBUG_DUMP_CLIP_COORDS
int tmpX1, tmpY1, tmpX2, tmpY2;
tmpX1 = x1;
tmpY1 = y1;
tmpX2 = x2;
tmpY2 = y2;
#endif
/* Left clip rectangle line. */ if( aClipBox->Inside( x1, y1 ) )
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, ax1, ay1, ax2, ay2 ) ) {
if( x1 == x2 ) /* Vertical line, clip Y. */
{
if( y2 < minY )
{
y2 = minY;
return false;
}
if( y2 > maxY )
{
y2 = maxY;
return false; return false;
}
}
else if( y1 == y2 ) /* Horizontal line, clip X. */
{
if( x2 < minX )
{
x2 = minX;
return false;
}
ax1 = rect.GetTopRight().x; if( x2 > maxX )
ay1 = rect.GetTopRight().y; {
x2 = maxX;
return false;
}
}
/* If we're here, it's a diagonal line. */
/* Top clip rectangle line. */ if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY,
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, ax1, ay1, ax2, ay2 ) ) &clippedX, &clippedY ) /* Left */
|| TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY,
&clippedX, &clippedY ) /* Top */
|| TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY,
&clippedX, &clippedY ) /* Right */
|| TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY,
&clippedX, &clippedY ) ) /* Bottom */
{
if( x2 != clippedX )
x2 = clippedX;
if( y2 != clippedY )
y2 = clippedY;
return false; return false;
}
ax2 = rect.GetBottomRight().x; /* If we're here, something has gone terribly wrong. */
ay2 = rect.GetBottomRight().y; #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)" ),
tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 );
#endif
return false;
}
else if( aClipBox->Inside( x2, y2 ) )
{
if( x1 == x2 ) /* Vertical line, clip Y. */
{
if( y2 < minY )
{
y2 = minY;
return false;
}
/* Right clip rectangle line. */ if( y2 > maxY )
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, ax1, ay1, ax2, ay2 ) ) {
y2 = maxY;
return false; return false;
}
}
else if( y1 == y2 ) /* Horizontal line, clip X. */
{
if( x2 < minX )
{
x2 = minX;
return false;
}
ax1 = rect.GetBottomLeft().x; if( x2 > maxX )
ay1 = rect.GetBottomLeft().y; {
x2 = maxX;
return false;
}
}
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY,
&clippedX, &clippedY ) /* Left */
|| TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY,
&clippedX, &clippedY ) /* Top */
|| TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY,
&clippedX, &clippedY ) /* Right */
|| TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY,
&clippedX, &clippedY ) ) /* Bottom */
{
if( x1 != clippedX )
x1 = clippedX;
if( y1 != clippedY )
y1 = clippedY;
return false;
}
/* 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)" ),
tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 );
#endif
return false;
}
else
{
int* intersectX;
int* intersectY;
int intersectX1, intersectY1, intersectX2, intersectY2;
bool haveFirstPoint = false;
intersectX = &intersectX1;
intersectY = &intersectY1;
/* Left clip rectangle line. */
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, minX, maxY,
intersectX, intersectY ) )
{
intersectX = &intersectX2;
intersectY = &intersectY2;
haveFirstPoint = true;
}
/* Top clip rectangle line. */
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, minY, maxX, minY,
intersectX, intersectY ) )
{
intersectX = &intersectX2;
intersectY = &intersectY2;
if( haveFirstPoint )
{
x1 = intersectX1;
y1 = intersectY1;
x2 = intersectX2;
y2 = intersectY2;
return false;
}
haveFirstPoint = true;
}
/* Right clip rectangle line. */
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, maxX, minY, maxX, maxY,
intersectX, intersectY ) )
{
intersectX = &intersectX2;
intersectY = &intersectY2;
if( haveFirstPoint )
{
x1 = intersectX1;
y1 = intersectY1;
x2 = intersectX2;
y2 = intersectY2;
return false;
}
haveFirstPoint = true;
}
/* Bottom clip rectangle line. */ /* Bottom clip rectangle line. */
if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, ax1, ay1, ax2, ay2 ) ) if( TestForIntersectionOfStraightLineSegments( x1, y1, x2, y2, minX, maxY, maxX, maxY,
intersectX, intersectY ) )
{
intersectX = &intersectX2;
intersectY = &intersectY2;
if( haveFirstPoint )
{
x1 = intersectX1;
y1 = intersectY1;
x2 = intersectX2;
y2 = intersectY2;
return false; return false;
}
}
/* If we're here and only one line of the clip box has been intersected,
* 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)" ),
tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY, x1, y1, x2, y2 );
#endif
}
/* Set this to one to verify that diagonal lines get clipped properly. */ /* Set this to one to verify that diagonal lines get clipped properly. */
#if 0 #if DEBUG_DUMP_CLIP_COORDS
if( !( x1 == x2 || y1 == y2 ) ) if( !( x1 == x2 || y1 == y2 ) )
wxLogDebug( wxT( "Clipped line (%d,%d):(%d,%d) from rectangle (%d,%d,%d,%d)" ), wxLogDebug( wxT( "Clipped line (%d,%d):(%d,%d) from rectangle (%d,%d,%d,%d)" ),
x1, y1, x2, y2, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height ); tmpX1, tmpY1, tmpX2, tmpY2, minX, minY, maxX, maxY );
#endif #endif
return true; return true;
} }
#else
/** /**
* Function clip_line * Function clip_line
* @return bool - true when WHEN_OUTSIDE fires, else false. * @return bool - true when WHEN_OUTSIDE fires, else false.
...@@ -306,8 +479,6 @@ static inline bool clip_line( int& x1, int& y1, int& x2, int& y2 ) ...@@ -306,8 +479,6 @@ static inline bool clip_line( int& x1, int& y1, int& x2, int& y2 )
return false; return false;
} }
#endif
static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC, static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
......
...@@ -54,11 +54,11 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) ...@@ -54,11 +54,11 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
if( !GetBaseScreen()->m_UserGridIsON ) if( !GetBaseScreen()->m_UserGridIsON )
{ {
int tmp = wxRound( coord->x / grid_size.x ); int tmp = wxRound( (double) coord->x / grid_size.x );
coord->x = wxRound( tmp * grid_size.x ); coord->x = wxRound( (double) tmp * grid_size.x );
tmp = wxRound( coord->y / grid_size.y ); tmp = wxRound( (double) coord->y / grid_size.y );
coord->y = wxRound( tmp * grid_size.y ); coord->y = wxRound( (double) tmp * grid_size.y );
} }
} }
......
...@@ -211,6 +211,7 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -211,6 +211,7 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
wxRealPoint delta; wxRealPoint delta;
int flagcurseur = 0; int flagcurseur = 0;
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
double scalar = GetScreen()->GetScalingFactor();
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
...@@ -219,13 +220,8 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -219,13 +220,8 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
delta = GetScreen()->GetGridSize(); delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
......
...@@ -216,13 +216,13 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( ...@@ -216,13 +216,13 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay(
} }
void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
wxPoint MousePositionInPixels )
{ {
wxRealPoint delta; wxRealPoint delta;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
double scalar = screen->GetScalingFactor();
ActiveScreen = screen; ActiveScreen = screen;
...@@ -231,13 +231,8 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -231,13 +231,8 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
delta = screen->GetGridSize(); delta = screen->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
MousePositionInPixels = DrawPanel->CalcUnscrolledPosition( MousePositionInPixels );
#else
screen->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
...@@ -317,13 +312,13 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -317,13 +312,13 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
} }
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
wxPoint MousePositionInPixels )
{ {
wxRealPoint delta; wxRealPoint delta;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
double scalar = screen->GetScalingFactor();
ActiveScreen = screen; ActiveScreen = screen;
...@@ -332,13 +327,8 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -332,13 +327,8 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
delta = screen->GetGridSize(); delta = screen->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
MousePositionInPixels = DrawPanel->CalcUnscrolledPosition( MousePositionInPixels );
#else
screen->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
...@@ -417,13 +407,13 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -417,13 +407,13 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
} }
void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
wxPoint MousePositionInPixels )
{ {
wxRealPoint delta; wxRealPoint delta;
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos; wxPoint curpos, oldpos;
int hotkey = 0; int hotkey = 0;
double scalar = screen->GetScalingFactor();
ActiveScreen = screen; ActiveScreen = screen;
...@@ -432,13 +422,8 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, ...@@ -432,13 +422,8 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
delta = screen->GetGridSize(); delta = screen->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
MousePositionInPixels = DrawPanel->CalcUnscrolledPosition( MousePositionInPixels );
#else
screen->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
......
...@@ -38,18 +38,15 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -38,18 +38,15 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
return; return;
} }
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( delta.x ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( delta.y );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta );
#endif
if( delta.x == 0 ) if( delta.x == 0 )
delta.x = 1; delta.x = 1;
......
...@@ -25,15 +25,6 @@ ...@@ -25,15 +25,6 @@
#include <wx/dcgraph.h> #include <wx/dcgraph.h>
#endif #endif
// Helper class to handle the client Device Context
class KicadGraphicContext : public wxClientDC
{
public:
KicadGraphicContext( WinEDA_DrawPanel * aDrawPanel );
~KicadGraphicContext();
};
// Macro used to declare a device context in kicad: // Macro used to declare a device context in kicad:
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM #if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM
#define INSTALL_DC(name,parent) \ #define INSTALL_DC(name,parent) \
......
...@@ -258,18 +258,15 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -258,18 +258,15 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
SetTitle( GetScreen()->m_FileName ); SetTitle( GetScreen()->m_FileName );
} }
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( delta.x ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( delta.y );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta );
#endif
if( delta.x <= 0 ) if( delta.x <= 0 )
delta.x = 1; delta.x = 1;
......
...@@ -451,18 +451,15 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -451,18 +451,15 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
return; return;
} }
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse ); curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); delta = GetScreen()->GetGridSize();
#ifdef USE_WX_ZOOM delta.x *= scalar;
delta.x = DC->LogicalToDeviceXRel( wxRound( delta.x ) ); delta.y *= scalar;
delta.y = DC->LogicalToDeviceYRel( wxRound( delta.y ) );
Mouse = DrawPanel->CalcUnscrolledPosition( Mouse );
#else
GetScreen()->Scale( delta );
#endif
if( delta.x == 0 ) if( delta.x == 0 )
delta.x = 1; delta.x = 1;
......
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