Commit 6fe086ab authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Added cursor snapping.

parent 215f35e2
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -987,9 +987,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )


        // Set up grid settings
        // Set up grid settings
        gal->SetGridVisibility( IsGridVisible() );
        gal->SetGridVisibility( IsGridVisible() );
        // Default grid color - dark cyan does not look good
        //gal->SetGridColor( KiGfx::COLOR4D( GetGridColor() ) );
        gal->SetGridColor( KiGfx::COLOR4D( 0.1, 0.1, 0.1, 1.0 ) );
        gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
        gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
        gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
        gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
        gal->SetGridOriginMarkerSize( 15 );
        gal->SetGridOriginMarkerSize( 15 );
+1 −1
Original line number Original line Diff line number Diff line
@@ -134,7 +134,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
    if( m_view->IsTargetDirty( KiGfx::TARGET_NONCACHED ) )
    if( m_view->IsTargetDirty( KiGfx::TARGET_NONCACHED ) )
        m_gal->DrawGrid();
        m_gal->DrawGrid();
    m_view->Redraw();
    m_view->Redraw();
    m_gal->DrawCursor( m_viewControls->GetMousePosition() );
    m_gal->DrawCursor( m_viewControls->GetCursorPosition() );


    m_gal->EndDrawing();
    m_gal->EndDrawing();


+3 −0
Original line number Original line Diff line number Diff line
@@ -69,6 +69,9 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
    screenSize = VECTOR2D( aParent->GetSize() );
    screenSize = VECTOR2D( aParent->GetSize() );
    initCursor( 20 );
    initCursor( 20 );


    // Grid color settings are different in Cairo and OpenGL
    SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) );

    // Allocate memory for pixel storage
    // Allocate memory for pixel storage
    allocateBitmaps();
    allocateBitmaps();
}
}
+11 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,6 @@ GAL::GAL() :
    // Set grid defaults
    // Set grid defaults
    SetGridVisibility( true );
    SetGridVisibility( true );
    SetGridStyle( GRID_STYLE_LINES );
    SetGridStyle( GRID_STYLE_LINES );
    SetGridColor( COLOR4D( 0.4, 0.4, 0.4, 1.0 ) );
    SetCoarseGrid( 10 );
    SetCoarseGrid( 10 );
    SetGridLineWidth( 0.5 );
    SetGridLineWidth( 0.5 );


@@ -230,3 +229,14 @@ void GAL::DrawGrid()
        }
        }
    }
    }
}
}


VECTOR2D GAL::GetGridPoint( VECTOR2D aPoint ) const
{
    VECTOR2D pointWorld = ToWorld( aPoint );

    pointWorld.x = round( pointWorld.x / gridSize.x ) * gridSize.x;
    pointWorld.y = round( pointWorld.y / gridSize.y ) * gridSize.y;

    return ToScreen( pointWorld );
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,9 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
    screenSize = VECTOR2D( aParent->GetSize() );
    screenSize = VECTOR2D( aParent->GetSize() );
    initCursor( 20 );
    initCursor( 20 );


    // Grid color settings are different in Cairo and OpenGL
    SetGridColor( COLOR4D( 0.8, 0.8, 0.8, 0.1 ) );

    // Tesselator initialization
    // Tesselator initialization
    tesselator = gluNewTess();
    tesselator = gluNewTess();
    InitTesselatorCallbacks( tesselator );
    InitTesselatorCallbacks( tesselator );
Loading