Introduced Cairo-based rendering backend using GAL.
Moved switching canvas routines to pcbnew, as they are used only there right now (otherwise libgal would have to be linked to every Kicad application).
This commit is contained in:
parent
5b9057823a
commit
820e6e5e16
|
@ -46,7 +46,10 @@
|
||||||
#include <math/box2.h>
|
#include <math/box2.h>
|
||||||
|
|
||||||
#include <wx/fontdlg.h>
|
#include <wx/fontdlg.h>
|
||||||
|
#ifdef KICAD_GAL
|
||||||
|
#include <view/view.h>
|
||||||
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
|
#endif /* KICAD_GAL */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Definition for enabling and disabling scroll bar setting trace output. See the
|
* Definition for enabling and disabling scroll bar setting trace output. See the
|
||||||
|
@ -67,7 +70,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, EDA_BASE_FRAME )
|
||||||
EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
|
EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
|
||||||
EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
|
EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
|
||||||
EVT_MENU_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, EDA_DRAW_FRAME::OnZoom )
|
EVT_MENU_RANGE( ID_ZOOM_IN, ID_ZOOM_REDRAW, EDA_DRAW_FRAME::OnZoom )
|
||||||
EVT_MENU( ID_SWITCH_CANVAS, EDA_DRAW_FRAME::OnZoom )
|
|
||||||
EVT_MENU_RANGE( ID_OFFCENTER_ZOOM_IN, ID_OFFCENTER_ZOOM_OUT, EDA_DRAW_FRAME::OnZoom )
|
EVT_MENU_RANGE( ID_OFFCENTER_ZOOM_IN, ID_OFFCENTER_ZOOM_OUT, EDA_DRAW_FRAME::OnZoom )
|
||||||
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
|
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
|
||||||
EDA_DRAW_FRAME::OnZoom )
|
EDA_DRAW_FRAME::OnZoom )
|
||||||
|
@ -943,22 +945,41 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
|
||||||
|
|
||||||
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
||||||
{
|
{
|
||||||
|
if( aEnable && m_galCanvasActive )
|
||||||
|
{
|
||||||
|
// When we switch between GAL based canvases, all we need is a refresh
|
||||||
|
m_galCanvas->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
if( !( aEnable ^ m_galCanvasActive ) )
|
if( !( aEnable ^ m_galCanvasActive ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
KiGfx::VIEW* view = m_galCanvas->GetView();
|
||||||
|
KiGfx::GAL* gal = m_galCanvas->GetGAL();
|
||||||
|
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||||
|
|
||||||
|
// Display the same view after canvas switching
|
||||||
if( aEnable )
|
if( aEnable )
|
||||||
{
|
{
|
||||||
m_canvas->Hide();
|
double zoom = 1 / ( zoomFactor * m_canvas->GetZoom() );
|
||||||
|
view->SetScale( zoom );
|
||||||
|
|
||||||
|
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
|
||||||
|
|
||||||
m_galCanvas->Show();
|
m_galCanvas->Show();
|
||||||
m_galCanvas->Raise();
|
|
||||||
m_galCanvas->Refresh();
|
m_galCanvas->Refresh();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_galCanvas->Hide();
|
m_galCanvas->Hide();
|
||||||
|
|
||||||
|
double zoom = 1 / ( zoomFactor * view->GetScale() );
|
||||||
|
m_canvas->SetZoom( zoom );
|
||||||
|
|
||||||
|
VECTOR2D center = view->GetCenter();
|
||||||
|
RedrawScreen( wxPoint( center.x, center.y ), false );
|
||||||
|
|
||||||
m_canvas->Show();
|
m_canvas->Show();
|
||||||
m_canvas->Raise();
|
|
||||||
m_canvas->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_galCanvasActive = aEnable;
|
m_galCanvasActive = aEnable;
|
||||||
|
|
|
@ -84,7 +84,11 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
|
||||||
m_gal->SetZoomFactor( 1.0 );
|
m_gal->SetZoomFactor( 1.0 );
|
||||||
m_gal->ComputeWorldScreenMatrix();
|
m_gal->ComputeWorldScreenMatrix();
|
||||||
|
|
||||||
|
m_painter = new KiGfx::PCB_PAINTER( m_gal );
|
||||||
|
m_painter->SetGAL( m_gal );
|
||||||
|
|
||||||
m_view = new KiGfx::VIEW( true );
|
m_view = new KiGfx::VIEW( true );
|
||||||
|
m_view->SetPainter( m_painter );
|
||||||
m_view->SetGAL( m_gal );
|
m_view->SetGAL( m_gal );
|
||||||
|
|
||||||
// View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
|
// View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
|
||||||
|
@ -150,4 +154,10 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType, bool aUseShaders )
|
||||||
|
|
||||||
if( m_view )
|
if( m_view )
|
||||||
m_view->SetGAL( m_gal );
|
m_view->SetGAL( m_gal );
|
||||||
|
|
||||||
|
if( m_painter )
|
||||||
|
m_painter->SetGAL( m_gal );
|
||||||
|
|
||||||
|
wxSize size = GetClientSize();
|
||||||
|
m_gal->ResizeScreen( size.GetX(), size.GetY() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,6 @@
|
||||||
#include <hotkeys_basic.h>
|
#include <hotkeys_basic.h>
|
||||||
#include <menus_helpers.h>
|
#include <menus_helpers.h>
|
||||||
#include <base_units.h>
|
#include <base_units.h>
|
||||||
#ifdef KICAD_GAL
|
|
||||||
#include <class_drawpanel_gal.h>
|
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
|
||||||
#include <view/view.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
|
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
|
||||||
|
@ -167,36 +162,6 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef KICAD_GAL
|
|
||||||
// Switch canvas between standard and GAL-based
|
|
||||||
case ID_SWITCH_CANVAS:
|
|
||||||
{
|
|
||||||
UseGalCanvas( !m_galCanvasActive );
|
|
||||||
|
|
||||||
KiGfx::VIEW* view = m_galCanvas->GetView();
|
|
||||||
KiGfx::GAL* gal = m_galCanvas->GetGAL();
|
|
||||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
|
||||||
|
|
||||||
// Display the same view after canvas switching
|
|
||||||
if( m_galCanvasActive )
|
|
||||||
{
|
|
||||||
double zoom = 1 / ( zoomFactor * m_canvas->GetZoom() );
|
|
||||||
view->SetScale( zoom );
|
|
||||||
|
|
||||||
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double zoom = 1 / ( zoomFactor * view->GetScale() );
|
|
||||||
m_canvas->SetZoom( zoom );
|
|
||||||
|
|
||||||
VECTOR2D center = view->GetCenter();
|
|
||||||
RedrawScreen( wxPoint( center.x, center.y ), false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case ID_POPUP_ZOOM_CENTER:
|
case ID_POPUP_ZOOM_CENTER:
|
||||||
center = screen->GetCrossHairPosition();
|
center = screen->GetCrossHairPosition();
|
||||||
RedrawScreen( center, true );
|
RedrawScreen( center, true );
|
||||||
|
|
|
@ -52,7 +52,6 @@ public:
|
||||||
enum GalType {
|
enum GalType {
|
||||||
GAL_TYPE_OPENGL, ///< OpenGL implementation
|
GAL_TYPE_OPENGL, ///< OpenGL implementation
|
||||||
GAL_TYPE_CAIRO, ///< Cairo implementation
|
GAL_TYPE_CAIRO, ///< Cairo implementation
|
||||||
GAL_TYPE_WXDC ///< WXDC implementation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
|
EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
|
||||||
|
|
|
@ -213,7 +213,6 @@ enum main_id
|
||||||
ID_ZOOM_OUT,
|
ID_ZOOM_OUT,
|
||||||
ID_ZOOM_PAGE,
|
ID_ZOOM_PAGE,
|
||||||
ID_ZOOM_REDRAW,
|
ID_ZOOM_REDRAW,
|
||||||
ID_SWITCH_CANVAS,
|
|
||||||
|
|
||||||
/* Panning command event IDs. */
|
/* Panning command event IDs. */
|
||||||
ID_PAN_UP,
|
ID_PAN_UP,
|
||||||
|
|
|
@ -581,6 +581,13 @@ public:
|
||||||
* displays the 3D view of current printed circuit board.
|
* displays the 3D view of current printed circuit board.
|
||||||
*/
|
*/
|
||||||
void Show3D_Frame( wxCommandEvent& event );
|
void Show3D_Frame( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function ChangeCanvas
|
||||||
|
* switches currently used canvas (default / Cairo / OpenGL).
|
||||||
|
*/
|
||||||
|
void SwitchCanvas( wxCommandEvent& aEvent );
|
||||||
|
|
||||||
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -83,7 +83,9 @@ static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
|
||||||
static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"),
|
static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"),
|
||||||
HK_SWITCH_HIGHCONTRAST_MODE,'H');
|
HK_SWITCH_HIGHCONTRAST_MODE,'H');
|
||||||
#ifdef KICAD_GAL
|
#ifdef KICAD_GAL
|
||||||
static EDA_HOTKEY HkSwitchCanvas( wxT( "Switch canvas" ), HK_SWITCH_CANVAS, WXK_F12 );
|
static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ), HK_CANVAS_DEFAULT, WXK_F10 );
|
||||||
|
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to OpenGL canvas" ), HK_CANVAS_OPENGL, WXK_F11 );
|
||||||
|
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to Cairo canvas" ), HK_CANVAS_CAIRO, WXK_F12 );
|
||||||
#endif
|
#endif
|
||||||
/* Fit on Screen */
|
/* Fit on Screen */
|
||||||
#if !defined( __WXMAC__ )
|
#if !defined( __WXMAC__ )
|
||||||
|
@ -232,7 +234,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
|
||||||
&HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9,
|
&HkRecordMacros8, &HkCallMacros8, &HkRecordMacros9, &HkCallMacros9,
|
||||||
&HkSwitchHighContrastMode,
|
&HkSwitchHighContrastMode,
|
||||||
#ifdef KICAD_GAL
|
#ifdef KICAD_GAL
|
||||||
&HkSwitchCanvas,
|
&HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,7 +83,9 @@ enum hotkey_id_commnand {
|
||||||
HK_MACRO_ID_END,
|
HK_MACRO_ID_END,
|
||||||
HK_SWITCH_HIGHCONTRAST_MODE,
|
HK_SWITCH_HIGHCONTRAST_MODE,
|
||||||
#ifdef KICAD_GAL
|
#ifdef KICAD_GAL
|
||||||
HK_SWITCH_CANVAS,
|
HK_CANVAS_DEFAULT,
|
||||||
|
HK_CANVAS_OPENGL,
|
||||||
|
HK_CANVAS_CAIRO,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -352,10 +352,25 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
// Switching GAL-based canvas on/off
|
// Switching GAL-based canvas on/off
|
||||||
viewMenu->AppendSeparator();
|
viewMenu->AppendSeparator();
|
||||||
|
|
||||||
text = AddHotkeyName( _( "&Switch canvas" ), g_Pcbnew_Editor_Hokeys_Descr, HK_SWITCH_CANVAS, IS_ACCELERATOR );
|
text = AddHotkeyName( _( "&Switch canvas to default" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
|
HK_CANVAS_DEFAULT, IS_ACCELERATOR );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_SWITCH_CANVAS,
|
AddMenuItem( viewMenu, ID_MENU_CANVAS_DEFAULT,
|
||||||
text, _( "Switch the canvas implementation between old (XOR-based) and new (GAL-based)" ),
|
text, _( "Switch the canvas implementation to default" ),
|
||||||
|
KiBitmap( tools_xpm ) );
|
||||||
|
|
||||||
|
text = AddHotkeyName( _( "&Switch canvas to OpenGL" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
|
HK_CANVAS_OPENGL, IS_ACCELERATOR );
|
||||||
|
|
||||||
|
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
|
||||||
|
text, _( "Switch the canvas implementation to OpenGL" ),
|
||||||
|
KiBitmap( tools_xpm ) );
|
||||||
|
|
||||||
|
text = AddHotkeyName( _( "&Switch canvas to Cairo" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
|
HK_CANVAS_CAIRO, IS_ACCELERATOR );
|
||||||
|
|
||||||
|
AddMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO,
|
||||||
|
text, _( "Switch the canvas implementation to Cairo" ),
|
||||||
KiBitmap( tools_xpm ) );
|
KiBitmap( tools_xpm ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@
|
||||||
#include <python_scripting.h>
|
#include <python_scripting.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(KICAD_GAL)
|
||||||
|
#include <class_drawpanel_gal.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Keys used in read/write config
|
// Keys used in read/write config
|
||||||
#define OPTKEY_DEFAULT_LINEWIDTH_VALUE wxT( "PlotLineWidth_mm" )
|
#define OPTKEY_DEFAULT_LINEWIDTH_VALUE wxT( "PlotLineWidth_mm" )
|
||||||
#define PCB_SHOW_FULL_RATSNET_OPT wxT( "PcbFullRatsnest" )
|
#define PCB_SHOW_FULL_RATSNET_OPT wxT( "PcbFullRatsnest" )
|
||||||
|
@ -152,6 +156,11 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
|
||||||
// Menu 3D Frame
|
// Menu 3D Frame
|
||||||
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
|
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
|
||||||
|
|
||||||
|
// Switching canvases
|
||||||
|
EVT_MENU( ID_MENU_CANVAS_DEFAULT, PCB_EDIT_FRAME::SwitchCanvas )
|
||||||
|
EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::SwitchCanvas )
|
||||||
|
EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::SwitchCanvas )
|
||||||
|
|
||||||
// Menu Get Design Rules Editor
|
// Menu Get Design Rules Editor
|
||||||
EVT_MENU( ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, PCB_EDIT_FRAME::ShowDesignRulesEditor )
|
EVT_MENU( ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, PCB_EDIT_FRAME::ShowDesignRulesEditor )
|
||||||
|
|
||||||
|
@ -557,6 +566,32 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
|
||||||
|
{
|
||||||
|
#ifdef KICAD_GAL
|
||||||
|
int id = aEvent.GetId();
|
||||||
|
|
||||||
|
switch( id )
|
||||||
|
{
|
||||||
|
case ID_MENU_CANVAS_DEFAULT:
|
||||||
|
UseGalCanvas( false );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ID_MENU_CANVAS_CAIRO:
|
||||||
|
m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO, false );
|
||||||
|
UseGalCanvas( true );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ID_MENU_CANVAS_OPENGL:
|
||||||
|
m_galCanvas->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL, false );
|
||||||
|
UseGalCanvas( true );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
|
void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
DIALOG_DESIGN_RULES dR_editor( this );
|
DIALOG_DESIGN_RULES dR_editor( this );
|
||||||
|
|
|
@ -266,6 +266,9 @@ enum pcbnew_ids
|
||||||
|
|
||||||
ID_PCB_GEN_CMP_FILE,
|
ID_PCB_GEN_CMP_FILE,
|
||||||
ID_MENU_PCB_SHOW_3D_FRAME,
|
ID_MENU_PCB_SHOW_3D_FRAME,
|
||||||
|
ID_MENU_CANVAS_DEFAULT,
|
||||||
|
ID_MENU_CANVAS_OPENGL,
|
||||||
|
ID_MENU_CANVAS_CAIRO,
|
||||||
ID_PCB_USER_GRID_SETUP,
|
ID_PCB_USER_GRID_SETUP,
|
||||||
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
|
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
|
||||||
ID_PCB_LIB_TABLE_EDIT,
|
ID_PCB_LIB_TABLE_EDIT,
|
||||||
|
|
Loading…
Reference in New Issue