Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-01-13 15:48:23 +00:00
|
|
|
* Copyright (C) 2013-2017 CERN
|
2023-03-10 17:15:40 +00:00
|
|
|
* Copyright (C) 2013-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-02-16 22:25:27 +00:00
|
|
|
*
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2015-02-15 01:18:35 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <confirm.h>
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-04-24 23:44:09 +00:00
|
|
|
#include <macros.h>
|
2022-07-13 03:02:58 +00:00
|
|
|
#include <scoped_set_reset.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/app_settings.h>
|
2021-03-22 19:34:33 +00:00
|
|
|
#include <trace_helpers.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2014-04-04 09:56:04 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <view/wx_view_controls.h>
|
2023-09-07 00:23:19 +00:00
|
|
|
#include <gal/painter.h>
|
2018-09-16 21:19:33 +00:00
|
|
|
#include <base_screen.h>
|
2021-04-05 01:35:01 +00:00
|
|
|
#include <gal/cursors.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
#include <gal/opengl/opengl_gal.h>
|
|
|
|
#include <gal/cairo/cairo_gal.h>
|
2023-02-19 03:40:07 +00:00
|
|
|
#include <math/vector2wx.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2020-10-12 01:44:46 +00:00
|
|
|
|
2013-08-02 14:53:50 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <widgets/wx_infobar.h>
|
2020-09-24 22:13:53 +00:00
|
|
|
|
2021-04-02 23:04:33 +00:00
|
|
|
#include <kiplatform/ui.h>
|
|
|
|
|
2023-09-07 11:22:10 +00:00
|
|
|
#include <core/profile.h>
|
2016-05-02 13:56:17 +00:00
|
|
|
|
2022-08-21 12:39:55 +00:00
|
|
|
#include <pgm_base.h>
|
2013-05-16 15:17:35 +00:00
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
|
|
|
const wxPoint& aPosition, const wxSize& aSize,
|
2021-02-16 22:25:27 +00:00
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
|
|
|
|
wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ),
|
2023-02-14 00:10:33 +00:00
|
|
|
m_MouseCapturedLost( false ),
|
|
|
|
m_parent( aParentWindow ),
|
2021-02-16 22:25:27 +00:00
|
|
|
m_edaFrame( nullptr ),
|
2023-07-01 16:30:19 +00:00
|
|
|
m_lastRepaintStart( 0 ),
|
|
|
|
m_lastRepaintEnd( 0 ),
|
2023-02-14 00:10:33 +00:00
|
|
|
m_drawing( false ),
|
|
|
|
m_drawingEnabled( false ),
|
2023-07-01 16:30:19 +00:00
|
|
|
m_needIdleRefresh( false ),
|
2021-02-16 22:25:27 +00:00
|
|
|
m_gal( nullptr ),
|
|
|
|
m_view( nullptr ),
|
|
|
|
m_painter( nullptr ),
|
|
|
|
m_viewControls( nullptr ),
|
|
|
|
m_backend( GAL_TYPE_NONE ),
|
|
|
|
m_options( aOptions ),
|
|
|
|
m_eventDispatcher( nullptr ),
|
|
|
|
m_lostFocus( false ),
|
2022-09-04 20:04:17 +00:00
|
|
|
m_stealsFocus( true ),
|
|
|
|
m_statusPopup( nullptr )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2021-12-05 20:15:18 +00:00
|
|
|
m_PaintEventCounter = std::make_unique<PROF_COUNTER>( "Draw panel paint events" );
|
|
|
|
|
2016-03-22 18:53:50 +00:00
|
|
|
SetLayoutDirection( wxLayout_LeftToRight );
|
|
|
|
|
2020-05-19 22:54:05 +00:00
|
|
|
m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_parent );
|
|
|
|
|
2020-04-26 10:30:32 +00:00
|
|
|
// If we're in a dialog, we have to go looking for our parent frame
|
|
|
|
if( !m_edaFrame )
|
|
|
|
{
|
|
|
|
wxWindow* ancestor = aParentWindow->GetParent();
|
|
|
|
|
|
|
|
while( ancestor && !dynamic_cast<EDA_DRAW_FRAME*>( ancestor ) )
|
|
|
|
ancestor = ancestor->GetParent();
|
|
|
|
|
|
|
|
if( ancestor )
|
|
|
|
m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( ancestor );
|
|
|
|
}
|
|
|
|
|
2013-07-29 14:38:07 +00:00
|
|
|
SwitchBackend( aGalType );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
2016-06-03 13:46:11 +00:00
|
|
|
|
2022-08-21 12:39:55 +00:00
|
|
|
if( Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
|
|
|
|
{
|
|
|
|
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
|
|
|
|
}
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
|
2022-01-31 15:45:47 +00:00
|
|
|
KIPLATFORM::UI::SetOverlayScrolling( this, false ); // Prevent excessive repaint on GTK
|
2023-05-10 00:30:15 +00:00
|
|
|
KIPLATFORM::UI::ImmControl( this, false ); // Ensure our panel can't suck in IME events
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), nullptr, this );
|
|
|
|
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), nullptr,
|
|
|
|
this );
|
|
|
|
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), nullptr,
|
|
|
|
this );
|
2013-10-14 11:43:57 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
const wxEventType events[] = {
|
2017-09-16 16:28:48 +00:00
|
|
|
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
|
|
|
|
// especially special key like arrow keys, are handled by the GAL event dispatcher,
|
|
|
|
// and not sent to GUI without filtering, because they have a default action (scroll)
|
|
|
|
// that must not be called.
|
2021-02-16 22:25:27 +00:00
|
|
|
wxEVT_LEFT_UP,
|
|
|
|
wxEVT_LEFT_DOWN,
|
|
|
|
wxEVT_LEFT_DCLICK,
|
|
|
|
wxEVT_RIGHT_UP,
|
|
|
|
wxEVT_RIGHT_DOWN,
|
|
|
|
wxEVT_RIGHT_DCLICK,
|
|
|
|
wxEVT_MIDDLE_UP,
|
|
|
|
wxEVT_MIDDLE_DOWN,
|
|
|
|
wxEVT_MIDDLE_DCLICK,
|
2022-06-02 21:56:17 +00:00
|
|
|
wxEVT_AUX1_UP,
|
|
|
|
wxEVT_AUX1_DOWN,
|
|
|
|
wxEVT_AUX1_DCLICK,
|
|
|
|
wxEVT_AUX2_UP,
|
|
|
|
wxEVT_AUX2_DOWN,
|
|
|
|
wxEVT_AUX2_DCLICK,
|
2021-02-16 22:25:27 +00:00
|
|
|
wxEVT_MOTION,
|
|
|
|
wxEVT_MOUSEWHEEL,
|
|
|
|
wxEVT_CHAR,
|
|
|
|
wxEVT_CHAR_HOOK,
|
2015-05-21 20:54:29 +00:00
|
|
|
wxEVT_MAGNIFY,
|
|
|
|
KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
|
2014-07-09 09:22:43 +00:00
|
|
|
};
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( wxEventType eventType : events )
|
2021-07-15 19:26:35 +00:00
|
|
|
Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::OnEvent ), nullptr,
|
2021-02-16 22:25:27 +00:00
|
|
|
m_eventDispatcher );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2023-07-01 16:30:19 +00:00
|
|
|
// Set up timer to detect when drawing starts
|
2016-05-09 15:23:01 +00:00
|
|
|
m_refreshTimer.SetOwner( this );
|
|
|
|
Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), nullptr, this );
|
2016-05-09 15:23:01 +00:00
|
|
|
|
|
|
|
// Set up timer to execute OnShow() method when the window appears on the screen
|
|
|
|
m_onShowTimer.SetOwner( this );
|
|
|
|
Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
|
2021-07-15 19:26:35 +00:00
|
|
|
wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), nullptr, this );
|
2016-05-09 15:23:01 +00:00
|
|
|
m_onShowTimer.Start( 10 );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
|
|
|
|
{
|
2016-06-03 13:46:12 +00:00
|
|
|
StopDrawing();
|
2016-05-02 14:15:25 +00:00
|
|
|
|
2018-01-17 07:58:44 +00:00
|
|
|
wxASSERT( !m_drawing );
|
2016-06-03 13:46:12 +00:00
|
|
|
|
2015-04-30 08:46:03 +00:00
|
|
|
delete m_viewControls;
|
|
|
|
delete m_view;
|
|
|
|
delete m_gal;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-25 09:21:00 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::SetFocus()
|
|
|
|
{
|
|
|
|
wxScrolledCanvas::SetFocus();
|
|
|
|
m_lostFocus = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 07:58:18 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
2013-04-16 09:16:27 +00:00
|
|
|
{
|
2020-07-13 17:53:07 +00:00
|
|
|
DoRePaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-17 09:42:22 +00:00
|
|
|
bool EDA_DRAW_PANEL_GAL::DoRePaint()
|
2020-07-13 17:53:07 +00:00
|
|
|
{
|
2022-07-28 03:26:39 +00:00
|
|
|
if( !m_refreshMutex.try_lock() )
|
2023-06-17 09:42:22 +00:00
|
|
|
return false;
|
2022-07-28 03:26:39 +00:00
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock( m_refreshMutex, std::adopt_lock );
|
|
|
|
|
2023-06-17 09:42:22 +00:00
|
|
|
if( !m_drawingEnabled )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_gal->IsInitialized() || !m_gal->IsVisible() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_drawing )
|
|
|
|
return false;
|
|
|
|
|
2023-07-01 16:30:19 +00:00
|
|
|
m_lastRepaintStart = wxGetLocalTimeMillis();
|
2023-06-17 09:42:22 +00:00
|
|
|
|
2020-07-13 17:53:07 +00:00
|
|
|
// Repaint the canvas, and fix scrollbar cursors
|
|
|
|
// Usually called by a OnPaint event, but because it does not use a wxPaintDC,
|
|
|
|
// it can be called outside a wxPaintEvent.
|
|
|
|
|
|
|
|
// Update current zoom settings if the canvas is managed by a EDA frame
|
2018-09-17 09:22:11 +00:00
|
|
|
// (i.e. not by a preview panel in a dialog)
|
2020-09-02 20:56:31 +00:00
|
|
|
if( !IsDialogPreview() && GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() )
|
2019-06-13 13:34:38 +00:00
|
|
|
GetParentEDAFrame()->GetScreen()->m_ScrollCenter = GetView()->GetCenter();
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2022-11-17 19:33:22 +00:00
|
|
|
if( Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
|
|
|
|
m_viewControls->UpdateScrollbars();
|
2019-08-22 05:05:15 +00:00
|
|
|
|
2022-07-13 03:02:58 +00:00
|
|
|
SCOPED_SET_RESET<bool> drawing( m_drawing, true );
|
|
|
|
|
2021-12-05 20:15:18 +00:00
|
|
|
( *m_PaintEventCounter )++;
|
|
|
|
|
2017-02-16 02:06:05 +00:00
|
|
|
wxASSERT( m_painter );
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
KIGFX::RENDER_SETTINGS* settings =
|
|
|
|
static_cast<KIGFX::RENDER_SETTINGS*>( m_painter->GetSettings() );
|
2013-11-11 09:48:49 +00:00
|
|
|
|
2021-12-05 19:16:18 +00:00
|
|
|
PROF_TIMER cntUpd("view-upd-items");
|
|
|
|
PROF_TIMER cntTotal("view-total");
|
|
|
|
PROF_TIMER cntCtx("view-context-create");
|
|
|
|
PROF_TIMER cntCtxDestroy("view-context-destroy");
|
|
|
|
PROF_TIMER cntRedraw("view-redraw-rects");
|
2021-11-28 20:51:19 +00:00
|
|
|
|
|
|
|
bool isDirty = false;
|
|
|
|
|
|
|
|
cntTotal.Start();
|
2017-01-13 15:48:23 +00:00
|
|
|
try
|
|
|
|
{
|
2021-11-28 20:51:19 +00:00
|
|
|
cntUpd.Start();
|
2022-02-13 18:40:30 +00:00
|
|
|
|
2022-01-05 21:34:12 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_view->UpdateItems();
|
|
|
|
}
|
|
|
|
catch( std::out_of_range& err )
|
|
|
|
{
|
|
|
|
// Don't do anything here but don't fail
|
|
|
|
// This can happen when we don't catch `at()` calls
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( wxT( "Out of Range error: %s" ), err.what() );
|
|
|
|
wxLogDebug( msg );
|
|
|
|
}
|
|
|
|
|
2021-11-28 20:51:19 +00:00
|
|
|
cntUpd.Stop();
|
2018-01-17 07:58:44 +00:00
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
// GAL_DRAWING_CONTEXT can throw in the dtor, so we need to scope
|
|
|
|
// the full lifetime inside the try block
|
2020-06-21 16:14:37 +00:00
|
|
|
{
|
2022-09-29 22:25:20 +00:00
|
|
|
cntCtx.Start();
|
|
|
|
KIGFX::GAL_DRAWING_CONTEXT ctx( m_gal );
|
|
|
|
cntCtx.Stop();
|
2020-06-21 16:14:37 +00:00
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
if( m_view->IsTargetDirty( KIGFX::TARGET_OVERLAY )
|
|
|
|
&& !m_gal->HasTarget( KIGFX::TARGET_OVERLAY ) )
|
|
|
|
{
|
|
|
|
m_view->MarkDirty();
|
|
|
|
}
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
m_gal->SetClearColor( settings->GetBackgroundColor() );
|
|
|
|
m_gal->SetGridColor( settings->GetGridColor() );
|
|
|
|
m_gal->SetCursorColor( settings->GetCursorColor() );
|
2018-09-16 11:30:18 +00:00
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
// TODO: find why ClearScreen() must be called here in opengl mode
|
|
|
|
// and only if m_view->IsDirty() in Cairo mode to avoid display artifacts
|
|
|
|
// when moving the mouse cursor
|
|
|
|
if( m_backend == GAL_TYPE_OPENGL )
|
2018-09-16 11:30:18 +00:00
|
|
|
m_gal->ClearScreen();
|
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
if( m_view->IsDirty() )
|
|
|
|
{
|
|
|
|
if( m_backend != GAL_TYPE_OPENGL // Already called in opengl
|
|
|
|
&& m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
|
|
|
|
{
|
|
|
|
m_gal->ClearScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_view->ClearTargets();
|
|
|
|
|
|
|
|
// Grid has to be redrawn only when the NONCACHED target is redrawn
|
|
|
|
if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
|
|
|
|
m_gal->DrawGrid();
|
|
|
|
|
|
|
|
cntRedraw.Start();
|
|
|
|
m_view->Redraw();
|
|
|
|
cntRedraw.Stop();
|
|
|
|
isDirty = true;
|
|
|
|
}
|
2015-02-15 01:18:35 +00:00
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
|
2013-04-16 09:16:27 +00:00
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
cntCtxDestroy.Start();
|
2017-01-13 15:48:23 +00:00
|
|
|
}
|
|
|
|
|
2022-09-29 22:25:20 +00:00
|
|
|
// ctx goes out of scope here so destructor would be called
|
|
|
|
cntCtxDestroy.Stop();
|
2015-02-15 01:18:35 +00:00
|
|
|
}
|
2021-02-22 13:15:09 +00:00
|
|
|
catch( std::exception& err )
|
2017-01-13 15:48:23 +00:00
|
|
|
{
|
2020-08-31 17:47:44 +00:00
|
|
|
if( GAL_FALLBACK != m_backend )
|
|
|
|
{
|
|
|
|
SwitchBackend( GAL_FALLBACK );
|
2017-01-13 15:48:23 +00:00
|
|
|
|
2020-08-31 17:47:44 +00:00
|
|
|
DisplayInfoMessage( m_parent,
|
|
|
|
_( "Could not use OpenGL, falling back to software rendering" ),
|
|
|
|
wxString( err.what() ) );
|
2023-07-10 04:24:52 +00:00
|
|
|
|
|
|
|
StartDrawing();
|
2020-08-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We're well and truly banjaxed if we get here without a fallback.
|
2023-07-10 04:25:42 +00:00
|
|
|
DisplayErrorMessage( m_parent, _( "Graphics error" ), wxString( err.what() ) );
|
|
|
|
|
|
|
|
StopDrawing();
|
2020-08-31 17:47:44 +00:00
|
|
|
}
|
2017-01-13 15:48:23 +00:00
|
|
|
}
|
2013-04-16 09:16:27 +00:00
|
|
|
|
2021-11-28 20:51:19 +00:00
|
|
|
if( isDirty )
|
|
|
|
{
|
2021-11-28 22:04:02 +00:00
|
|
|
KI_TRACE( traceGalProfile, "View timing: %s %s %s %s %s\n",
|
2021-11-28 20:51:19 +00:00
|
|
|
cntTotal.to_string(),
|
|
|
|
cntUpd.to_string(),
|
2021-11-28 22:04:02 +00:00
|
|
|
cntRedraw.to_string(),
|
2021-11-28 20:51:19 +00:00
|
|
|
cntCtx.to_string(),
|
2021-11-28 22:04:02 +00:00
|
|
|
cntCtxDestroy.to_string()
|
2021-11-28 20:51:19 +00:00
|
|
|
);
|
|
|
|
}
|
2016-05-02 13:56:17 +00:00
|
|
|
|
2023-07-01 16:30:19 +00:00
|
|
|
m_lastRepaintEnd = wxGetLocalTimeMillis();
|
|
|
|
|
2023-06-17 09:42:22 +00:00
|
|
|
return true;
|
2013-04-16 09:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-27 16:08:32 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
|
|
|
|
{
|
2021-01-09 20:13:46 +00:00
|
|
|
// If we get a second wx update call before the first finishes, don't crash
|
|
|
|
if( m_gal->IsContextLocked() )
|
|
|
|
return;
|
|
|
|
|
2018-10-15 13:07:52 +00:00
|
|
|
KIGFX::GAL_CONTEXT_LOCKER locker( m_gal );
|
2021-02-16 22:25:27 +00:00
|
|
|
wxSize clientSize = GetClientSize();
|
2020-10-01 16:44:19 +00:00
|
|
|
WX_INFOBAR* infobar = GetParentEDAFrame() ? GetParentEDAFrame()->GetInfoBar() : nullptr;
|
2020-09-24 22:13:53 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
if( ToVECTOR2I( clientSize ) == m_gal->GetScreenPixelSize() )
|
2020-09-24 22:13:53 +00:00
|
|
|
return;
|
|
|
|
|
2023-06-02 14:46:46 +00:00
|
|
|
// Note: ( +1, +1 ) prevents an ugly black line on right and bottom on Mac
|
|
|
|
clientSize.x = std::max( 10, clientSize.x + 1 );
|
|
|
|
clientSize.y = std::max( 10, clientSize.y + 1 );
|
2020-09-24 22:13:53 +00:00
|
|
|
|
|
|
|
VECTOR2D bottom( 0, 0 );
|
|
|
|
|
|
|
|
if( m_view )
|
|
|
|
bottom = m_view->ToWorld( m_gal->GetScreenPixelSize(), true );
|
|
|
|
|
2023-06-02 14:46:46 +00:00
|
|
|
m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
|
2018-09-10 09:16:59 +00:00
|
|
|
|
|
|
|
if( m_view )
|
|
|
|
{
|
2020-09-24 22:13:53 +00:00
|
|
|
if( infobar && infobar->IsLocked() )
|
2023-06-02 14:46:46 +00:00
|
|
|
{
|
|
|
|
VECTOR2D halfScreen( std::ceil( 0.5 * clientSize.x ), std::ceil( 0.5 * clientSize.y ) );
|
|
|
|
m_view->SetCenter( bottom - m_view->ToWorld( halfScreen, false ) );
|
|
|
|
}
|
2020-09-24 22:13:53 +00:00
|
|
|
|
2018-09-10 09:16:59 +00:00
|
|
|
m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
|
|
|
|
m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
|
|
}
|
2013-08-27 16:08:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 08:57:32 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
|
2013-09-12 09:40:16 +00:00
|
|
|
{
|
2023-07-01 16:30:19 +00:00
|
|
|
if( !DoRePaint() )
|
|
|
|
m_needIdleRefresh = true;
|
2013-10-14 11:43:57 +00:00
|
|
|
}
|
2013-09-12 09:40:16 +00:00
|
|
|
|
|
|
|
|
2014-10-13 13:22:45 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::ForceRefresh()
|
|
|
|
{
|
2023-09-02 21:13:48 +00:00
|
|
|
if( !m_drawingEnabled )
|
|
|
|
{
|
|
|
|
if( m_gal && m_gal->IsInitialized() )
|
|
|
|
{
|
|
|
|
Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr,
|
|
|
|
this );
|
|
|
|
|
|
|
|
Connect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_PANEL_GAL::onIdle ), nullptr, this );
|
|
|
|
|
|
|
|
m_drawingEnabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Try again soon
|
|
|
|
m_refreshTimer.StartOnce( 100 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-13 17:53:07 +00:00
|
|
|
DoRePaint();
|
2014-10-13 13:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
|
|
|
|
{
|
|
|
|
m_eventDispatcher = aEventDispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::StartDrawing()
|
|
|
|
{
|
2015-08-21 08:33:36 +00:00
|
|
|
// Start querying GAL if it is ready
|
|
|
|
m_refreshTimer.StartOnce( 100 );
|
2014-05-13 09:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-05 13:54:30 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::StopDrawing()
|
|
|
|
{
|
2022-04-28 22:34:44 +00:00
|
|
|
m_refreshTimer.Stop();
|
2015-08-21 08:33:36 +00:00
|
|
|
m_drawingEnabled = false;
|
2023-07-01 16:30:19 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr, this );
|
2023-07-01 16:30:19 +00:00
|
|
|
|
|
|
|
Disconnect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_PANEL_GAL::onIdle ), nullptr, this );
|
2013-12-05 13:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-17 00:59:31 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
|
|
|
// Set display settings for high contrast mode
|
|
|
|
KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
|
|
|
|
|
|
|
|
SetTopLayer( aLayer );
|
|
|
|
|
2020-10-03 21:26:44 +00:00
|
|
|
rSettings->ClearHighContrastLayers();
|
|
|
|
rSettings->SetLayerIsHighContrast( aLayer );
|
2014-07-09 08:57:32 +00:00
|
|
|
|
|
|
|
m_view->UpdateAllLayersColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-17 00:59:31 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
|
|
|
m_view->ClearTopLayers();
|
|
|
|
m_view->SetTopLayer( aLayer );
|
|
|
|
m_view->UpdateAllLayersOrder();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-07 16:24:43 +00:00
|
|
|
bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-06-04 14:18:33 +00:00
|
|
|
// Do not do anything if the currently used GAL is correct
|
2021-07-15 19:26:35 +00:00
|
|
|
if( aGalType == m_backend && m_gal != nullptr )
|
2015-02-15 01:18:35 +00:00
|
|
|
return true;
|
2013-05-15 07:17:42 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
VECTOR2D grid_size = m_gal ? m_gal->GetGridSize() : VECTOR2D();
|
|
|
|
bool grid_visibility = m_gal ? m_gal->GetGridVisibility() : true;
|
|
|
|
bool result = true; // assume everything will be fine
|
2015-08-21 08:33:36 +00:00
|
|
|
|
2014-04-04 10:01:30 +00:00
|
|
|
// Prevent refreshing canvas during backend switch
|
2014-05-13 09:22:51 +00:00
|
|
|
StopDrawing();
|
2014-04-04 10:01:30 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
KIGFX::GAL* new_gal = nullptr;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2015-02-15 01:18:35 +00:00
|
|
|
try
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2015-02-15 01:18:35 +00:00
|
|
|
switch( aGalType )
|
|
|
|
{
|
|
|
|
case GAL_TYPE_OPENGL:
|
2020-07-03 19:57:00 +00:00
|
|
|
{
|
|
|
|
wxString errormsg = KIGFX::OPENGL_GAL::CheckFeatures( m_options );
|
|
|
|
|
|
|
|
if( errormsg.empty() )
|
2018-11-24 03:50:09 +00:00
|
|
|
{
|
2023-09-07 00:07:09 +00:00
|
|
|
new_gal = new KIGFX::OPENGL_GAL( GetVcSettings(), m_options, this, this, this );
|
2018-11-24 03:50:09 +00:00
|
|
|
}
|
2020-07-03 19:57:00 +00:00
|
|
|
else
|
2018-11-24 03:50:09 +00:00
|
|
|
{
|
2020-08-31 17:47:44 +00:00
|
|
|
if( GAL_FALLBACK != aGalType )
|
|
|
|
{
|
|
|
|
aGalType = GAL_FALLBACK;
|
2021-02-16 22:25:27 +00:00
|
|
|
DisplayInfoMessage(
|
|
|
|
m_parent,
|
|
|
|
_( "Could not use OpenGL, falling back to software rendering" ),
|
|
|
|
errormsg );
|
2020-08-31 17:47:44 +00:00
|
|
|
new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We're well and truly banjaxed if we get here without a fallback.
|
|
|
|
DisplayInfoMessage( m_parent, _( "Could not use OpenGL" ), errormsg );
|
|
|
|
}
|
2018-11-24 03:50:09 +00:00
|
|
|
}
|
2019-01-09 13:31:46 +00:00
|
|
|
break;
|
2020-07-03 19:57:00 +00:00
|
|
|
}
|
2019-01-09 13:31:46 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
case GAL_TYPE_CAIRO: new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this ); break;
|
2013-06-18 14:19:30 +00:00
|
|
|
|
2015-08-07 17:15:47 +00:00
|
|
|
default:
|
2018-09-10 13:37:28 +00:00
|
|
|
wxASSERT( false );
|
2020-04-24 23:44:09 +00:00
|
|
|
KI_FALLTHROUGH;
|
2015-08-21 08:33:36 +00:00
|
|
|
// warn about unhandled GAL canvas type, but continue with the fallback option
|
2013-05-14 08:46:43 +00:00
|
|
|
|
2015-08-21 08:33:36 +00:00
|
|
|
case GAL_TYPE_NONE:
|
2015-10-25 16:58:04 +00:00
|
|
|
// KIGFX::GAL is a stub - it actually does cannot display anything,
|
2015-08-21 08:33:36 +00:00
|
|
|
// but prevents code relying on GAL canvas existence from crashing
|
2017-02-13 11:43:28 +00:00
|
|
|
new_gal = new KIGFX::GAL( m_options );
|
2015-08-21 08:33:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-02-15 01:18:35 +00:00
|
|
|
}
|
2015-04-30 08:46:03 +00:00
|
|
|
catch( std::runtime_error& err )
|
2015-02-15 01:18:35 +00:00
|
|
|
{
|
2018-01-17 07:58:44 +00:00
|
|
|
// Create a dummy GAL
|
2017-02-13 11:43:28 +00:00
|
|
|
new_gal = new KIGFX::GAL( m_options );
|
2015-08-21 08:33:36 +00:00
|
|
|
aGalType = GAL_TYPE_NONE;
|
2015-05-18 11:48:10 +00:00
|
|
|
DisplayError( m_parent, wxString( err.what() ) );
|
2015-08-21 08:33:36 +00:00
|
|
|
result = false;
|
2015-02-15 01:18:35 +00:00
|
|
|
}
|
2013-04-15 15:57:03 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
// trigger update of the gal options in case they differ from the defaults
|
2017-02-13 11:43:28 +00:00
|
|
|
m_options.NotifyChanged();
|
2016-05-02 14:15:25 +00:00
|
|
|
|
2015-08-21 08:33:36 +00:00
|
|
|
delete m_gal;
|
|
|
|
m_gal = new_gal;
|
|
|
|
|
2020-03-04 20:33:42 +00:00
|
|
|
wxSize clientSize = GetClientSize();
|
|
|
|
clientSize.x = std::max( 10, clientSize.x );
|
|
|
|
clientSize.y = std::max( 10, clientSize.y );
|
|
|
|
m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
|
2015-08-21 08:33:36 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
if( grid_size.x > 0 && grid_size.y > 0 )
|
|
|
|
m_gal->SetGridSize( grid_size );
|
|
|
|
|
|
|
|
m_gal->SetGridVisibility( grid_visibility );
|
|
|
|
|
2021-04-05 01:35:01 +00:00
|
|
|
// Make sure the cursor is set on the new canvas
|
|
|
|
SetCurrentCursor( KICURSOR::ARROW );
|
|
|
|
|
2015-08-21 08:33:36 +00:00
|
|
|
if( m_painter )
|
|
|
|
m_painter->SetGAL( m_gal );
|
|
|
|
|
|
|
|
if( m_view )
|
2017-09-17 22:36:18 +00:00
|
|
|
{
|
2015-08-21 08:33:36 +00:00
|
|
|
m_view->SetGAL( m_gal );
|
2017-09-17 22:36:18 +00:00
|
|
|
// Note: OpenGL requires reverse draw order when draw priority is enabled
|
|
|
|
m_view->ReverseDrawOrder( aGalType == GAL_TYPE_OPENGL );
|
|
|
|
}
|
2015-08-21 08:33:36 +00:00
|
|
|
|
|
|
|
m_backend = aGalType;
|
|
|
|
|
|
|
|
return result;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
2013-08-02 14:53:50 +00:00
|
|
|
|
2013-08-07 07:37:28 +00:00
|
|
|
|
2018-05-20 13:08:06 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::OnEvent( wxEvent& aEvent )
|
2014-07-09 09:22:43 +00:00
|
|
|
{
|
2021-04-02 23:04:33 +00:00
|
|
|
bool shouldSetFocus = m_lostFocus && m_stealsFocus
|
|
|
|
&& !KIUI::IsInputControlFocused() // Don't steal from input controls
|
|
|
|
&& !KIUI::IsModalDialogFocused() // Don't steal from dialogs
|
|
|
|
&& KIPLATFORM::UI::IsWindowActive( m_edaFrame ); // Don't steal from other windows
|
2020-10-17 02:54:36 +00:00
|
|
|
|
|
|
|
if( shouldSetFocus )
|
2015-07-02 09:40:33 +00:00
|
|
|
SetFocus();
|
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
if( !m_eventDispatcher )
|
|
|
|
aEvent.Skip();
|
|
|
|
else
|
|
|
|
m_eventDispatcher->DispatchWxEvent( aEvent );
|
|
|
|
|
2023-07-01 16:30:19 +00:00
|
|
|
// Give events time to process, based on last render duration
|
|
|
|
wxLongLong endDelta = wxGetLocalTimeMillis() - m_lastRepaintEnd;
|
|
|
|
long long timeLimit = ( m_lastRepaintEnd - m_lastRepaintStart ).GetValue() / 5;
|
|
|
|
|
|
|
|
timeLimit = std::clamp( timeLimit, 3LL, 150LL );
|
|
|
|
|
|
|
|
if( endDelta > timeLimit )
|
|
|
|
Refresh();
|
|
|
|
else
|
|
|
|
m_needIdleRefresh = true;
|
2014-07-09 09:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 02:54:36 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::onEnter( wxMouseEvent& aEvent )
|
2013-09-09 15:07:03 +00:00
|
|
|
{
|
2021-04-02 23:04:33 +00:00
|
|
|
bool shouldSetFocus = m_stealsFocus
|
|
|
|
&& !KIUI::IsInputControlFocused() // Don't steal from input controls
|
|
|
|
&& !KIUI::IsModalDialogFocused() // Don't steal from dialogs
|
|
|
|
&& KIPLATFORM::UI::IsWindowActive( m_edaFrame ); // Don't steal from other windows
|
2020-10-17 02:54:36 +00:00
|
|
|
|
2013-09-13 08:26:08 +00:00
|
|
|
// Getting focus is necessary in order to receive key events properly
|
2020-10-17 02:54:36 +00:00
|
|
|
if( shouldSetFocus )
|
2017-03-03 21:05:13 +00:00
|
|
|
SetFocus();
|
2015-08-25 09:21:00 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
2013-09-09 15:07:03 +00:00
|
|
|
}
|
2015-07-02 09:40:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_lostFocus = true;
|
2015-08-25 09:21:00 +00:00
|
|
|
|
2021-01-24 17:17:51 +00:00
|
|
|
m_viewControls->CancelDrag();
|
|
|
|
|
2015-08-25 09:21:00 +00:00
|
|
|
aEvent.Skip();
|
2015-07-02 09:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-01 16:30:19 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::onIdle( wxIdleEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_needIdleRefresh )
|
|
|
|
{
|
|
|
|
m_needIdleRefresh = false;
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-02 09:40:33 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
2023-09-02 21:13:48 +00:00
|
|
|
ForceRefresh();
|
2015-07-02 09:40:33 +00:00
|
|
|
}
|
2016-05-02 14:15:25 +00:00
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
|
|
|
|
void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
2023-04-12 02:09:05 +00:00
|
|
|
if( m_gal && m_gal->IsInitialized() && m_gal->IsVisible() )
|
2016-05-09 15:23:01 +00:00
|
|
|
{
|
|
|
|
m_onShowTimer.Stop();
|
|
|
|
OnShow();
|
|
|
|
}
|
|
|
|
}
|
2019-06-27 21:33:48 +00:00
|
|
|
|
|
|
|
|
2021-04-05 01:35:01 +00:00
|
|
|
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( KICURSOR aCursor )
|
2019-06-27 21:33:48 +00:00
|
|
|
{
|
2021-04-05 01:35:01 +00:00
|
|
|
if( m_gal )
|
|
|
|
m_gal->SetNativeCursorStyle( aCursor );
|
2019-06-27 21:33:48 +00:00
|
|
|
}
|
2020-10-06 09:22:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<KIGFX::VIEW_OVERLAY> EDA_DRAW_PANEL_GAL::DebugOverlay()
|
|
|
|
{
|
|
|
|
if( !m_debugOverlay )
|
|
|
|
{
|
|
|
|
m_debugOverlay.reset( new KIGFX::VIEW_OVERLAY() );
|
|
|
|
m_view->Add( m_debugOverlay.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_debugOverlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EDA_DRAW_PANEL_GAL::ClearDebugOverlay()
|
|
|
|
{
|
|
|
|
if( m_debugOverlay )
|
|
|
|
{
|
|
|
|
m_view->Remove( m_debugOverlay.get() );
|
|
|
|
m_debugOverlay = nullptr;
|
|
|
|
}
|
2021-01-09 20:13:46 +00:00
|
|
|
}
|
2023-09-07 00:07:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
KIGFX::VC_SETTINGS EDA_DRAW_PANEL_GAL::GetVcSettings()
|
|
|
|
{
|
|
|
|
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
|
|
|
|
|
|
|
KIGFX::VC_SETTINGS vcSettings;
|
|
|
|
vcSettings.m_warpCursor = cfg->m_Input.center_on_zoom;
|
|
|
|
vcSettings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb;
|
|
|
|
vcSettings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan;
|
|
|
|
vcSettings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration;
|
|
|
|
vcSettings.m_horizontalPan = cfg->m_Input.horizontal_pan;
|
|
|
|
vcSettings.m_zoomAcceleration = cfg->m_Input.zoom_acceleration;
|
|
|
|
vcSettings.m_zoomSpeed = cfg->m_Input.zoom_speed;
|
|
|
|
vcSettings.m_zoomSpeedAuto = cfg->m_Input.zoom_speed_auto;
|
|
|
|
vcSettings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom;
|
|
|
|
vcSettings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h;
|
|
|
|
vcSettings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v;
|
|
|
|
vcSettings.m_dragLeft = cfg->m_Input.drag_left;
|
|
|
|
vcSettings.m_dragMiddle = cfg->m_Input.drag_middle;
|
|
|
|
vcSettings.m_dragRight = cfg->m_Input.drag_right;
|
|
|
|
vcSettings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h;
|
|
|
|
|
|
|
|
return vcSettings;
|
|
|
|
}
|