From 8ad15b1d666be1a4647fa9bf068259a44a6e7499 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 24 Feb 2019 12:56:17 +0100 Subject: [PATCH] Symbol editor: fix issues related to axis not shown. In Symbol editor, axis are always shown. However after switching the backend, axis were no longer drawn. In Cairo engine, fix a bug preventing axis to be shown. --- common/gal/cairo/cairo_gal.cpp | 10 ++++++---- eeschema/libedit/lib_edit_frame.cpp | 10 ++++++++++ eeschema/libedit/lib_edit_frame.h | 5 +++++ eeschema/sch_base_frame.h | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index 2a09fce474..2ea9cd2947 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -904,14 +904,16 @@ void CAIRO_GAL_BASE::resetContext() void CAIRO_GAL_BASE::drawAxes( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) { syncLineWidth(); + auto p0 = roundp( xform( aStartPoint ) ); auto p1 = roundp( xform( aEndPoint ) ); + auto org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord - cairo_move_to( currentContext, p0.x, 0.0); - cairo_line_to( currentContext, p1.x, 0.0 ); - cairo_move_to( currentContext, 0.0, p0.y ); - cairo_line_to( currentContext, 0.0, p1.y ); cairo_set_source_rgba( currentContext, axesColor.r, axesColor.g, axesColor.b, axesColor.a ); + cairo_move_to( currentContext, p0.x, org.y); + cairo_line_to( currentContext, p1.x, org.y ); + cairo_move_to( currentContext, org.x, p0.y ); + cairo_line_to( currentContext, org.x, p1.y ); cairo_stroke( currentContext ); } diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 8da78ab2e2..a1ad3d8636 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -1840,3 +1840,13 @@ void LIB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) ; } } + + +void LIB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent ) +{ + // switches currently used canvas ( Cairo / OpenGL): + SCH_BASE_FRAME::OnSwitchCanvas( aEvent ); + + // Set options specific to symbol editor (axies are always enabled): + GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); +} diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 9576726813..6e0148ca34 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -154,6 +154,11 @@ public: ~LIB_EDIT_FRAME(); + /** + * switches currently used canvas ( Cairo / OpenGL). + */ + void OnSwitchCanvas( wxCommandEvent& aEvent ) override; + /** The nickname of the current library being edited and empty string if none. */ wxString GetCurLib() const; diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index a3c1c99673..876303963b 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -112,7 +112,7 @@ public: /** * switches currently used canvas ( Cairo / OpenGL). */ - void OnSwitchCanvas( wxCommandEvent& aEvent ); + virtual void OnSwitchCanvas( wxCommandEvent& aEvent ); /** * Update UI called when switches currently used canvas (Cairo / OpenGL).