Commit d657b430 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

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
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -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)

+0 −3
Original line number Diff line number Diff line
@@ -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

+2 −117
Original line number Diff line number Diff line
@@ -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() )
+0 −4
Original line number Diff line number Diff line
@@ -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 );

+5 −6
Original line number Diff line number Diff line
@@ -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 );
Loading