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.
This commit is contained in:
jean-pierre charras 2019-02-24 12:56:17 +01:00
parent 30612ca62d
commit 8ad15b1d66
4 changed files with 22 additions and 5 deletions

View File

@ -904,14 +904,16 @@ void CAIRO_GAL_BASE::resetContext()
void CAIRO_GAL_BASE::drawAxes( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) void CAIRO_GAL_BASE::drawAxes( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint )
{ {
syncLineWidth(); syncLineWidth();
auto p0 = roundp( xform( aStartPoint ) ); auto p0 = roundp( xform( aStartPoint ) );
auto p1 = roundp( xform( aEndPoint ) ); 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_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 ); cairo_stroke( currentContext );
} }

View File

@ -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 );
}

View File

@ -154,6 +154,11 @@ public:
~LIB_EDIT_FRAME(); ~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. */ /** The nickname of the current library being edited and empty string if none. */
wxString GetCurLib() const; wxString GetCurLib() const;

View File

@ -112,7 +112,7 @@ public:
/** /**
* switches currently used canvas ( Cairo / OpenGL). * 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). * Update UI called when switches currently used canvas (Cairo / OpenGL).