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.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
|
2021-02-16 22:25:27 +00:00
|
|
|
* Copyright (C) 2012-2021 Kicad Developers, see AUTHORS.txt for contributors.
|
2017-01-13 15:48:23 +00:00
|
|
|
* Copyright (C) 2013-2017 CERN
|
2013-05-15 14:48:10 +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
|
|
|
*
|
|
|
|
* Graphics Abstraction Layer (GAL) for OpenGL
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-12-28 16:05:03 +00:00
|
|
|
// Apple, in their infinite wisdom, has decided to mark OpenGL as deprecated.
|
|
|
|
// Luckily we can silence warnings about its deprecation.
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#define GL_SILENCE_DEPRECATION 1
|
|
|
|
#endif
|
|
|
|
|
2020-06-26 17:39:43 +00:00
|
|
|
#include <gl_utils.h>
|
|
|
|
|
2020-08-12 13:16:57 +00:00
|
|
|
#include <advanced_config.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/opengl/opengl_gal.h>
|
2016-05-02 14:04:45 +00:00
|
|
|
#include <gal/opengl/utils.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/definitions.h>
|
2016-06-03 13:46:12 +00:00
|
|
|
#include <gl_context_mgr.h>
|
2017-01-24 13:31:57 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2018-06-06 16:59:16 +00:00
|
|
|
#include <bitmap_base.h>
|
2019-11-09 10:14:20 +00:00
|
|
|
#include <bezier_curves.h>
|
2021-02-16 22:25:27 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
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
|
|
|
|
2020-10-18 11:31:07 +00:00
|
|
|
#include <wx/frame.h>
|
|
|
|
|
2013-04-12 07:30:18 +00:00
|
|
|
#include <macros.h>
|
2021-09-06 14:36:28 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2016-05-02 13:56:17 +00:00
|
|
|
|
2013-04-30 13:59:32 +00:00
|
|
|
#include <profile.h>
|
2021-11-28 21:29:06 +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
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <limits>
|
|
|
|
#include <memory>
|
2016-06-29 10:23:11 +00:00
|
|
|
using namespace std::placeholders;
|
2013-10-14 14:13:35 +00:00
|
|
|
using namespace KIGFX;
|
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
|
|
|
|
2018-12-30 19:30:43 +00:00
|
|
|
// A ugly workaround to avoid serious issues (crashes) when using bitmaps cache
|
|
|
|
// to speedup redraw.
|
|
|
|
// issues arise when using bitmaps in page layout, when the page layout containd bitmaps,
|
|
|
|
// and is common to schematic and board editor,
|
|
|
|
// and the schematic is a hierarchy and when using cross-probing
|
|
|
|
// When the cross probing from pcbnew to eeschema switches to a sheet, the bitmaps cache
|
|
|
|
// becomes broken (in fact the associated texture).
|
2021-04-05 13:24:57 +00:00
|
|
|
// I hope (JPC) it will be fixed later, but a slightly slower refresh is better than a crash
|
2018-12-30 19:30:43 +00:00
|
|
|
#define DISABLE_BITMAP_CACHE
|
2016-12-22 14:26:31 +00:00
|
|
|
|
2016-08-03 15:02:43 +00:00
|
|
|
// The current font is "Ubuntu Mono" available under Ubuntu Font Licence 1.0
|
|
|
|
// (see ubuntu-font-licence-1.0.txt for details)
|
2016-12-22 14:26:31 +00:00
|
|
|
#include "gl_resources.h"
|
2016-12-22 15:11:28 +00:00
|
|
|
#include "gl_builtin_shaders.h"
|
2016-12-22 14:26:31 +00:00
|
|
|
using namespace KIGFX::BUILTIN_FONT;
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
static void InitTesselatorCallbacks( GLUtesselator* aTesselator );
|
2016-05-02 13:56:10 +00:00
|
|
|
static const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 };
|
2016-05-02 13:56:16 +00:00
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
wxGLContext* OPENGL_GAL::m_glMainContext = nullptr;
|
2021-03-19 21:38:53 +00:00
|
|
|
int OPENGL_GAL::m_instanceCounter = 0;
|
|
|
|
GLuint OPENGL_GAL::g_fontTexture = 0;
|
|
|
|
bool OPENGL_GAL::m_isBitmapFontLoaded = false;
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
2018-07-30 14:18:53 +00:00
|
|
|
class GL_BITMAP_CACHE
|
2018-07-29 22:11:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-02-16 22:25:27 +00:00
|
|
|
GL_BITMAP_CACHE() {}
|
2018-07-29 22:11:47 +00:00
|
|
|
|
|
|
|
~GL_BITMAP_CACHE();
|
2018-07-30 14:18:53 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
GLuint RequestBitmap( const BITMAP_BASE* aBitmap );
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct CACHED_BITMAP
|
|
|
|
{
|
|
|
|
GLuint id;
|
2021-02-16 22:25:27 +00:00
|
|
|
int w, h;
|
2018-07-29 22:11:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GLuint cacheBitmap( const BITMAP_BASE* aBitmap );
|
2018-07-30 14:18:53 +00:00
|
|
|
|
|
|
|
std::map<const BITMAP_BASE*, CACHED_BITMAP> m_bitmaps;
|
2018-07-29 22:11:47 +00:00
|
|
|
};
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
}; // namespace KIGFX
|
2018-07-29 22:11:47 +00:00
|
|
|
|
2018-09-22 21:01:47 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
GL_BITMAP_CACHE::~GL_BITMAP_CACHE()
|
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
for( auto& bitmap : m_bitmaps )
|
|
|
|
glDeleteTextures( 1, &bitmap.second.id );
|
2018-07-29 22:11:47 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 21:01:47 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
GLuint GL_BITMAP_CACHE::RequestBitmap( const BITMAP_BASE* aBitmap )
|
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
auto it = m_bitmaps.find( aBitmap );
|
2018-07-29 22:11:47 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
if( it != m_bitmaps.end() )
|
2018-07-29 22:11:47 +00:00
|
|
|
{
|
2018-12-30 19:30:43 +00:00
|
|
|
// A bitmap is found in cache bitmap.
|
2019-08-20 17:22:30 +00:00
|
|
|
// Ensure the associated texture is still valid (can be destroyed somewhere)
|
2018-12-30 19:30:43 +00:00
|
|
|
if( glIsTexture( it->second.id ) )
|
|
|
|
return it->second.id;
|
|
|
|
|
|
|
|
// else if not valid, it will be recreated.
|
2018-07-29 22:11:47 +00:00
|
|
|
}
|
2018-12-30 19:30:43 +00:00
|
|
|
|
|
|
|
return cacheBitmap( aBitmap );
|
2018-07-29 22:11:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GLuint GL_BITMAP_CACHE::cacheBitmap( const BITMAP_BASE* aBitmap )
|
|
|
|
{
|
|
|
|
CACHED_BITMAP bmp;
|
|
|
|
|
|
|
|
bmp.w = aBitmap->GetSizePixels().x;
|
|
|
|
bmp.h = aBitmap->GetSizePixels().y;
|
|
|
|
|
2018-01-04 06:02:17 +00:00
|
|
|
// The bitmap size needs to be a multiple of 4.
|
|
|
|
// This is easiest to achieve by ensuring that each row
|
|
|
|
// has a multiple of 4 pixels
|
|
|
|
int extra_w = bmp.w % 4;
|
|
|
|
|
|
|
|
if( extra_w )
|
|
|
|
extra_w = 4 - extra_w;
|
2018-07-30 14:18:53 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
GLuint textureID;
|
2021-02-16 22:25:27 +00:00
|
|
|
glGenTextures( 1, &textureID );
|
2018-07-29 22:11:47 +00:00
|
|
|
|
2018-01-04 06:02:17 +00:00
|
|
|
// make_unique initializes this to 0, so extra pixels are transparent
|
2021-02-16 22:25:27 +00:00
|
|
|
auto buf = std::make_unique<uint8_t[]>( ( bmp.w + extra_w ) * bmp.h * 4 );
|
2019-04-24 09:50:18 +00:00
|
|
|
const wxImage& imgData = *aBitmap->GetImageData();
|
2018-07-29 22:11:47 +00:00
|
|
|
|
2018-07-30 14:18:53 +00:00
|
|
|
for( int y = 0; y < bmp.h; y++ )
|
|
|
|
{
|
|
|
|
for( int x = 0; x < bmp.w; x++ )
|
2018-07-29 22:11:47 +00:00
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
uint8_t* p = buf.get() + ( ( bmp.w + extra_w ) * y + x ) * 4;
|
2018-07-29 22:11:47 +00:00
|
|
|
|
2019-04-24 09:50:18 +00:00
|
|
|
p[0] = imgData.GetRed( x, y );
|
|
|
|
p[1] = imgData.GetGreen( x, y );
|
|
|
|
p[2] = imgData.GetBlue( x, y );
|
2018-01-04 06:02:17 +00:00
|
|
|
|
2019-04-24 09:50:18 +00:00
|
|
|
if( imgData.HasAlpha() )
|
|
|
|
p[3] = imgData.GetAlpha( x, y );
|
2021-02-16 22:25:27 +00:00
|
|
|
else if( imgData.HasMask() && p[0] == imgData.GetMaskRed()
|
|
|
|
&& p[1] == imgData.GetMaskGreen() && p[2] == imgData.GetMaskBlue() )
|
2019-02-08 05:26:27 +00:00
|
|
|
p[3] = wxALPHA_TRANSPARENT;
|
2018-01-04 06:02:17 +00:00
|
|
|
else
|
2019-02-08 05:26:27 +00:00
|
|
|
p[3] = wxALPHA_OPAQUE;
|
2018-07-29 22:11:47 +00:00
|
|
|
}
|
2018-07-30 14:18:53 +00:00
|
|
|
}
|
2018-07-29 22:11:47 +00:00
|
|
|
|
|
|
|
glBindTexture( GL_TEXTURE_2D, textureID );
|
2021-02-16 22:25:27 +00:00
|
|
|
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, bmp.w + extra_w, bmp.h, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
|
|
|
buf.get() );
|
2018-07-29 22:11:47 +00:00
|
|
|
|
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
|
|
|
|
|
|
|
bmp.id = textureID;
|
|
|
|
|
2018-12-30 19:30:43 +00:00
|
|
|
#ifndef DISABLE_BITMAP_CACHE
|
2021-02-16 22:25:27 +00:00
|
|
|
m_bitmaps[aBitmap] = bmp;
|
2018-12-30 19:30:43 +00:00
|
|
|
#endif
|
2018-07-29 22:11:47 +00:00
|
|
|
|
|
|
|
return textureID;
|
|
|
|
}
|
2016-06-03 13:46:11 +00:00
|
|
|
|
2016-12-23 15:21:00 +00:00
|
|
|
OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
|
|
|
wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener,
|
|
|
|
const wxString& aName ) :
|
2021-02-16 22:25:27 +00:00
|
|
|
GAL( aDisplayOptions ),
|
|
|
|
HIDPI_GL_CANVAS( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxEXPAND, aName ),
|
2021-03-19 21:38:53 +00:00
|
|
|
m_mouseListener( aMouseListener ),
|
|
|
|
m_paintListener( aPaintListener ),
|
|
|
|
m_currentManager( nullptr ),
|
|
|
|
m_cachedManager( nullptr ),
|
|
|
|
m_nonCachedManager( nullptr ),
|
|
|
|
m_overlayManager( nullptr ),
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempManager( nullptr ),
|
2021-03-19 21:38:53 +00:00
|
|
|
m_mainBuffer( 0 ),
|
|
|
|
m_overlayBuffer( 0 ),
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempBuffer( 0 ),
|
2021-02-16 22:25:27 +00:00
|
|
|
m_isContextLocked( false ),
|
2021-03-19 21:38:53 +00:00
|
|
|
m_lockClientCookie( 0 )
|
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
|
|
|
if( m_glMainContext == nullptr )
|
2016-06-03 13:46:12 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_glMainContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
|
2018-06-11 10:25:20 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_glPrivContext = m_glMainContext;
|
2016-06-03 13:46:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_glPrivContext = GL_CONTEXT_MANAGER::Get().CreateCtx( this, m_glMainContext );
|
2016-06-03 13:46:12 +00:00
|
|
|
}
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_shader = new SHADER();
|
|
|
|
++m_instanceCounter;
|
2016-06-10 15:07:12 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_bitmapCache = std::make_unique<GL_BITMAP_CACHE>();
|
2018-07-29 22:11:47 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor = new OPENGL_COMPOSITOR;
|
|
|
|
m_compositor->SetAntialiasingMode( m_options.gl_antialiasing_mode );
|
2015-02-15 01:18: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
|
|
|
// Initialize the flags
|
2021-03-19 21:38:53 +00:00
|
|
|
m_isFramebufferInitialized = false;
|
|
|
|
m_isBitmapFontInitialized = false;
|
|
|
|
m_isInitialized = false;
|
|
|
|
m_isGrouping = false;
|
|
|
|
m_groupCounter = 0;
|
2013-04-30 13:59:32 +00:00
|
|
|
|
2021-04-05 01:35:01 +00:00
|
|
|
// Connect the native cursor handler
|
2021-07-15 19:26:35 +00:00
|
|
|
Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( OPENGL_GAL::onSetNativeCursor ), nullptr,
|
2021-04-05 01:35:01 +00:00
|
|
|
this );
|
|
|
|
|
2013-07-30 15:09:06 +00:00
|
|
|
// Connecting the event handlers
|
2021-02-16 22:25:27 +00:00
|
|
|
Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) );
|
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
|
|
|
|
|
|
|
// Mouse events are skipped to the parent
|
2021-02-16 22:25:27 +00:00
|
|
|
Connect( wxEVT_MOTION, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
|
|
|
Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
2016-01-25 00:18:29 +00:00
|
|
|
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
2021-02-16 22:25:27 +00:00
|
|
|
Connect( wxEVT_MAGNIFY, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
2015-05-21 20:54:29 +00:00
|
|
|
#endif
|
2013-04-22 09:08:02 +00:00
|
|
|
#if defined _WIN32 || defined _WIN64
|
2021-02-16 22:25:27 +00:00
|
|
|
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( OPENGL_GAL::skipMouseEvent ) );
|
2013-04-22 09:08:02 +00:00
|
|
|
#endif
|
2013-05-15 14:48:10 +00:00
|
|
|
|
2017-09-14 14:13:50 +00:00
|
|
|
SetSize( aParent->GetClientSize() );
|
2021-03-19 21:38:53 +00:00
|
|
|
m_screenSize = VECTOR2I( GetNativePixelSize() );
|
2015-07-01 01:46:42 +00:00
|
|
|
|
2013-08-28 14:25:42 +00:00
|
|
|
// Grid color settings are different in Cairo and OpenGL
|
|
|
|
SetGridColor( COLOR4D( 0.8, 0.8, 0.8, 0.1 ) );
|
2017-03-08 08:37:12 +00:00
|
|
|
SetAxesColor( COLOR4D( BLUE ) );
|
2013-08-28 14:25:42 +00:00
|
|
|
|
2013-06-18 14:20:29 +00:00
|
|
|
// Tesselator initialization
|
2021-03-19 21:38:53 +00:00
|
|
|
m_tesselator = gluNewTess();
|
|
|
|
InitTesselatorCallbacks( m_tesselator );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
gluTessProperty( m_tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
|
2014-02-25 13:28:09 +00:00
|
|
|
|
2017-01-23 05:19:10 +00:00
|
|
|
SetTarget( TARGET_NONCACHED );
|
2020-02-01 14:15:51 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Avoid uninitialized variables:
|
2020-02-01 14:15:51 +00:00
|
|
|
ufm_worldPixelSize = 1;
|
|
|
|
ufm_screenPixelSize = 1;
|
|
|
|
ufm_pixelSizeMultiplier = 1;
|
2021-06-02 13:04:23 +00:00
|
|
|
ufm_antialiasingOffset = 1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OPENGL_GAL::~OPENGL_GAL()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().LockCtx( m_glPrivContext, this );
|
2016-06-03 13:46:12 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
--m_instanceCounter;
|
2016-06-07 12:42:42 +00:00
|
|
|
glFlush();
|
2021-03-19 21:38:53 +00:00
|
|
|
gluDeleteTess( m_tesselator );
|
2016-05-09 15:23:01 +00:00
|
|
|
ClearCache();
|
2016-06-07 12:42:42 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
delete m_compositor;
|
2017-08-08 12:25:03 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isInitialized )
|
2017-08-08 12:25:03 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
delete m_cachedManager;
|
|
|
|
delete m_nonCachedManager;
|
|
|
|
delete m_overlayManager;
|
2022-01-02 15:00:07 +00:00
|
|
|
delete m_tempManager;
|
2017-08-08 12:25:03 +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
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glPrivContext );
|
2016-06-10 15:07:12 +00:00
|
|
|
|
|
|
|
// If it was the main context, then it will be deleted
|
|
|
|
// when the last OpenGL GAL instance is destroyed (a few lines below)
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_glPrivContext != m_glMainContext )
|
|
|
|
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glPrivContext );
|
2016-06-10 15:07:12 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
delete m_shader;
|
2019-02-25 12:51:02 +00:00
|
|
|
|
2016-06-13 07:35:36 +00:00
|
|
|
// Are we destroying the last GAL instance?
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_instanceCounter == 0 )
|
2016-05-02 13:56:16 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().LockCtx( m_glMainContext, this );
|
2016-06-10 15:07:12 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isBitmapFontLoaded )
|
2016-05-09 15:23:01 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
glDeleteTextures( 1, &g_fontTexture );
|
|
|
|
m_isBitmapFontLoaded = false;
|
2016-05-09 15:23:01 +00:00
|
|
|
}
|
2016-06-03 13:46:12 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glMainContext );
|
|
|
|
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glMainContext );
|
2021-07-15 19:26:35 +00:00
|
|
|
m_glMainContext = nullptr;
|
2016-05-02 13:56:16 +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
|
|
|
}
|
|
|
|
|
2017-01-13 15:48:23 +00:00
|
|
|
|
2020-07-03 19:57:00 +00:00
|
|
|
wxString OPENGL_GAL::CheckFeatures( GAL_DISPLAY_OPTIONS& aOptions )
|
|
|
|
{
|
2020-10-30 18:58:26 +00:00
|
|
|
wxString retVal = wxEmptyString;
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
wxFrame* testFrame = new wxFrame( nullptr, wxID_ANY, wxT( "" ), wxDefaultPosition,
|
|
|
|
wxSize( 1, 1 ), wxFRAME_TOOL_WINDOW | wxNO_BORDER );
|
2020-10-30 18:58:26 +00:00
|
|
|
|
2021-01-28 18:55:24 +00:00
|
|
|
KIGFX::OPENGL_GAL* opengl_gal = nullptr;
|
2020-07-03 19:57:00 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2021-01-28 18:55:24 +00:00
|
|
|
opengl_gal = new KIGFX::OPENGL_GAL( aOptions, testFrame );
|
|
|
|
|
|
|
|
testFrame->Raise();
|
|
|
|
testFrame->Show();
|
|
|
|
|
2020-07-03 19:57:00 +00:00
|
|
|
GAL_CONTEXT_LOCKER lock( opengl_gal );
|
|
|
|
opengl_gal->init();
|
|
|
|
}
|
|
|
|
catch( std::runtime_error& err )
|
|
|
|
{
|
|
|
|
//Test failed
|
2020-10-30 18:58:26 +00:00
|
|
|
retVal = wxString( err.what() );
|
2020-07-03 19:57:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete opengl_gal;
|
|
|
|
delete testFrame;
|
2020-10-30 18:58:26 +00:00
|
|
|
|
|
|
|
return retVal;
|
2020-07-03 19:57:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-15 12:00:58 +00:00
|
|
|
void OPENGL_GAL::PostPaint( wxPaintEvent& aEvent )
|
2020-07-15 10:58:43 +00:00
|
|
|
{
|
|
|
|
// posts an event to m_paint_listener to ask for redraw the canvas.
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_paintListener )
|
|
|
|
wxPostEvent( m_paintListener, aEvent );
|
2020-07-15 10:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-13 11:43:28 +00:00
|
|
|
bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
|
2016-12-23 15:21:00 +00:00
|
|
|
{
|
2021-08-26 13:44:39 +00:00
|
|
|
GAL_CONTEXT_LOCKER lock( this );
|
|
|
|
|
2017-02-13 11:43:28 +00:00
|
|
|
bool refresh = false;
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_options.gl_antialiasing_mode != m_compositor->GetAntialiasingMode() )
|
2016-12-23 15:21:00 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetAntialiasingMode( m_options.gl_antialiasing_mode );
|
|
|
|
m_isFramebufferInitialized = false;
|
2017-02-13 11:43:28 +00:00
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_options.m_scaleFactor != GetScaleFactor() )
|
2019-03-22 21:15:26 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
SetScaleFactor( m_options.m_scaleFactor );
|
2019-03-22 21:15:26 +00:00
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-02-13 11:43:28 +00:00
|
|
|
if( super::updatedGalDisplayOptions( aOptions ) || refresh )
|
|
|
|
{
|
2016-12-23 15:21:00 +00:00
|
|
|
Refresh();
|
2017-02-13 11:43:28 +00:00
|
|
|
refresh = true;
|
2016-12-23 15:21:00 +00:00
|
|
|
}
|
2017-02-13 11:43:28 +00:00
|
|
|
|
|
|
|
return refresh;
|
2016-12-23 15:21:00 +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
|
|
|
|
2019-02-16 19:25:10 +00:00
|
|
|
|
2018-10-12 17:08:25 +00:00
|
|
|
double OPENGL_GAL::getWorldPixelSize() const
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
MATRIX3x3D matrix = GetScreenWorldMatrix();
|
2018-10-13 11:39:09 +00:00
|
|
|
return std::min( std::abs( matrix.GetScale().x ), std::abs( matrix.GetScale().y ) );
|
2018-10-12 17:08:25 +00:00
|
|
|
}
|
2017-01-13 15:48:23 +00:00
|
|
|
|
2019-02-16 19:25:10 +00:00
|
|
|
|
2019-01-21 18:42:06 +00:00
|
|
|
VECTOR2D OPENGL_GAL::getScreenPixelSize() const
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
double sf = GetScaleFactor();
|
2021-07-15 19:26:35 +00:00
|
|
|
return VECTOR2D( 2.0 / (double) ( m_screenSize.x * sf ), 2.0 /
|
|
|
|
(double) ( m_screenSize.y * sf ) );
|
2019-01-21 18:42:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-28 15:39:10 +00:00
|
|
|
void OPENGL_GAL::BeginDrawing()
|
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-04-30 23:24:09 +00:00
|
|
|
#ifdef KICAD_GAL_PROFILE
|
2018-10-26 21:25:09 +00:00
|
|
|
PROF_COUNTER totalRealTime( "OPENGL_GAL::beginDrawing()", true );
|
2021-04-30 23:24:09 +00:00
|
|
|
#endif /* KICAD_GAL_PROFILE */
|
2016-05-02 13:56:17 +00:00
|
|
|
|
2021-01-09 20:13:46 +00:00
|
|
|
wxASSERT_MSG( m_isContextLocked, "GAL_DRAWING_CONTEXT RAII object should have locked context. "
|
2021-02-16 22:25:27 +00:00
|
|
|
"Calling GAL::beginDrawing() directly is not allowed." );
|
2018-10-26 21:25:09 +00:00
|
|
|
|
|
|
|
wxASSERT_MSG( IsVisible(), "GAL::beginDrawing() must not be entered when GAL is not visible. "
|
|
|
|
"Other drawing routines will expect everything to be initialized "
|
|
|
|
"which will not be the case." );
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_isInitialized )
|
2017-01-13 15:48:23 +00:00
|
|
|
init();
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
// Set up the view port
|
|
|
|
glMatrixMode( GL_PROJECTION );
|
|
|
|
glLoadIdentity();
|
2013-07-23 16:39:07 +00:00
|
|
|
|
2016-12-22 17:58:29 +00:00
|
|
|
// Create the screen transformation (Do the RH-LH conversion here)
|
2021-03-19 21:38:53 +00:00
|
|
|
glOrtho( 0, (GLint) m_screenSize.x, (GLsizei) m_screenSize.y, 0,
|
|
|
|
-m_depthRange.x, -m_depthRange.y );
|
2013-07-23 16:39:07 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_isFramebufferInitialized )
|
2014-07-09 09:22:42 +00:00
|
|
|
{
|
2018-10-12 22:42:44 +00:00
|
|
|
// Prepare rendering target buffers
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->Initialize();
|
|
|
|
m_mainBuffer = m_compositor->CreateBuffer();
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempBuffer = m_compositor->CreateBuffer();
|
2020-06-21 16:14:37 +00:00
|
|
|
try
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_overlayBuffer = m_compositor->CreateBuffer();
|
2020-06-21 16:14:37 +00:00
|
|
|
}
|
2021-02-20 16:50:10 +00:00
|
|
|
catch( const std::runtime_error& )
|
2020-06-21 16:14:37 +00:00
|
|
|
{
|
|
|
|
wxLogVerbose( "Could not create a framebuffer for overlays.\n" );
|
2021-03-19 21:38:53 +00:00
|
|
|
m_overlayBuffer = 0;
|
2020-06-21 16:14:37 +00:00
|
|
|
}
|
2021-07-15 19:26:35 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_isFramebufferInitialized = true;
|
2013-07-23 16:39:07 +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
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->Begin();
|
2016-12-22 17:58:29 +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
|
|
|
// Disable 2D Textures
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
|
2016-05-02 14:12:15 +00:00
|
|
|
glShadeModel( GL_FLAT );
|
|
|
|
|
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
|
|
|
// Enable the depth buffer
|
|
|
|
glEnable( GL_DEPTH_TEST );
|
|
|
|
glDepthFunc( GL_LESS );
|
2013-07-23 16:39:07 +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
|
|
|
// Setup blending, required for transparent objects
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
|
|
|
|
glMatrixMode( GL_MODELVIEW );
|
|
|
|
|
|
|
|
// Set up the world <-> screen transformation
|
|
|
|
ComputeWorldScreenMatrix();
|
|
|
|
GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
|
2021-03-19 21:38:53 +00:00
|
|
|
matrixData[0] = m_worldScreenMatrix.m_data[0][0];
|
|
|
|
matrixData[1] = m_worldScreenMatrix.m_data[1][0];
|
|
|
|
matrixData[2] = m_worldScreenMatrix.m_data[2][0];
|
|
|
|
matrixData[4] = m_worldScreenMatrix.m_data[0][1];
|
|
|
|
matrixData[5] = m_worldScreenMatrix.m_data[1][1];
|
|
|
|
matrixData[6] = m_worldScreenMatrix.m_data[2][1];
|
|
|
|
matrixData[12] = m_worldScreenMatrix.m_data[0][2];
|
|
|
|
matrixData[13] = m_worldScreenMatrix.m_data[1][2];
|
|
|
|
matrixData[14] = m_worldScreenMatrix.m_data[2][2];
|
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
|
|
|
glLoadMatrixd( matrixData );
|
|
|
|
|
|
|
|
// Set defaults
|
2021-03-19 21:38:53 +00:00
|
|
|
SetFillColor( m_fillColor );
|
|
|
|
SetStrokeColor( m_strokeColor );
|
2013-04-30 15:55:24 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
// Remove all previously stored items
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->Clear();
|
|
|
|
m_overlayManager->Clear();
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempManager->Clear();
|
2013-07-05 12:01:33 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->BeginDrawing();
|
|
|
|
m_nonCachedManager->BeginDrawing();
|
|
|
|
m_overlayManager->BeginDrawing();
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempManager->BeginDrawing();
|
2016-05-02 13:56:17 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_isBitmapFontInitialized )
|
2016-05-02 14:04:45 +00:00
|
|
|
{
|
|
|
|
// Keep bitmap font texture always bound to the second texturing unit
|
|
|
|
const GLint FONT_TEXTURE_UNIT = 2;
|
|
|
|
|
2016-06-03 13:46:12 +00:00
|
|
|
// Either load the font atlas to video memory, or simply bind it to a texture unit
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_isBitmapFontLoaded )
|
2016-05-02 14:04:45 +00:00
|
|
|
{
|
|
|
|
glActiveTexture( GL_TEXTURE0 + FONT_TEXTURE_UNIT );
|
2021-03-19 21:38:53 +00:00
|
|
|
glGenTextures( 1, &g_fontTexture );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, g_fontTexture );
|
2021-02-16 22:25:27 +00:00
|
|
|
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, font_image.width, font_image.height, 0, GL_RGB,
|
|
|
|
GL_UNSIGNED_BYTE, font_image.pixels );
|
2016-09-14 08:00:49 +00:00
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
|
2016-05-02 14:12:14 +00:00
|
|
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
2021-03-22 19:34:33 +00:00
|
|
|
checkGlError( "loading bitmap font", __FILE__, __LINE__ );
|
2016-05-02 14:04:45 +00:00
|
|
|
|
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_isBitmapFontLoaded = true;
|
2016-05-02 14:04:45 +00:00
|
|
|
}
|
2016-06-03 13:46:12 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
glActiveTexture( GL_TEXTURE0 + FONT_TEXTURE_UNIT );
|
2021-03-19 21:38:53 +00:00
|
|
|
glBindTexture( GL_TEXTURE_2D, g_fontTexture );
|
2016-06-03 13:46:12 +00:00
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
|
|
|
}
|
2016-05-02 14:04:45 +00:00
|
|
|
|
|
|
|
// Set shader parameter
|
2021-03-19 21:38:53 +00:00
|
|
|
GLint ufm_fontTexture = m_shader->AddParameter( "fontTexture" );
|
|
|
|
GLint ufm_fontTextureWidth = m_shader->AddParameter( "fontTextureWidth" );
|
|
|
|
ufm_worldPixelSize = m_shader->AddParameter( "worldPixelSize" );
|
|
|
|
ufm_screenPixelSize = m_shader->AddParameter( "screenPixelSize" );
|
|
|
|
ufm_pixelSizeMultiplier = m_shader->AddParameter( "pixelSizeMultiplier" );
|
2021-06-02 13:04:23 +00:00
|
|
|
ufm_antialiasingOffset = m_shader->AddParameter( "antialiasingOffset" );
|
2021-03-19 21:38:53 +00:00
|
|
|
|
|
|
|
m_shader->Use();
|
|
|
|
m_shader->SetParameter( ufm_fontTexture, (int) FONT_TEXTURE_UNIT );
|
|
|
|
m_shader->SetParameter( ufm_fontTextureWidth, (int) font_image.width );
|
|
|
|
m_shader->Deactivate();
|
2021-03-22 19:34:33 +00:00
|
|
|
checkGlError( "setting bitmap font sampler as shader parameter", __FILE__, __LINE__ );
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_isBitmapFontInitialized = true;
|
2016-05-02 14:04:45 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_shader->Use();
|
2021-03-22 19:34:33 +00:00
|
|
|
m_shader->SetParameter( ufm_worldPixelSize,
|
|
|
|
(float) ( getWorldPixelSize() / GetScaleFactor() ) );
|
2021-06-02 13:04:23 +00:00
|
|
|
const VECTOR2D& screenPixelSize = getScreenPixelSize();
|
|
|
|
m_shader->SetParameter( ufm_screenPixelSize, screenPixelSize );
|
2021-03-19 21:38:53 +00:00
|
|
|
double pixelSizeMultiplier = m_compositor->GetAntialiasSupersamplingFactor();
|
|
|
|
m_shader->SetParameter( ufm_pixelSizeMultiplier, (float) pixelSizeMultiplier );
|
2021-06-02 13:04:23 +00:00
|
|
|
VECTOR2D renderingOffset = m_compositor->GetAntialiasRenderingOffset();
|
|
|
|
renderingOffset.x *= screenPixelSize.x;
|
|
|
|
renderingOffset.y *= screenPixelSize.y;
|
|
|
|
m_shader->SetParameter( ufm_antialiasingOffset, renderingOffset );
|
2021-03-19 21:38:53 +00:00
|
|
|
m_shader->Deactivate();
|
2018-10-12 17:08:25 +00:00
|
|
|
|
2016-12-22 19:02:34 +00:00
|
|
|
// Something betreen BeginDrawing and EndDrawing seems to depend on
|
|
|
|
// this texture unit being active, but it does not assure it itself.
|
2017-01-13 09:36:59 +00:00
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
2016-12-22 19:02:34 +00:00
|
|
|
|
2016-05-02 14:04:45 +00:00
|
|
|
// Unbind buffers - set compositor for direct drawing
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2021-04-30 23:24:09 +00:00
|
|
|
#ifdef KICAD_GAL_PROFILE
|
2017-01-02 12:49:36 +00:00
|
|
|
totalRealTime.Stop();
|
2021-03-22 19:34:33 +00:00
|
|
|
wxLogTrace( traceGalProfile, wxT( "OPENGL_GAL::beginDrawing(): %.1f ms" ),
|
2021-02-16 22:25:27 +00:00
|
|
|
totalRealTime.msecs() );
|
2021-04-30 23:24:09 +00:00
|
|
|
#endif /* KICAD_GAL_PROFILE */
|
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-11-28 15:39:10 +00:00
|
|
|
void OPENGL_GAL::EndDrawing()
|
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-01-09 20:13:46 +00:00
|
|
|
wxASSERT_MSG( m_isContextLocked, "What happened to the context lock?" );
|
2018-10-12 22:42:44 +00:00
|
|
|
|
2021-12-05 19:16:18 +00:00
|
|
|
PROF_TIMER cntTotal("gl-end-total");
|
|
|
|
PROF_TIMER cntEndCached("gl-end-cached");
|
|
|
|
PROF_TIMER cntEndNoncached("gl-end-noncached");
|
|
|
|
PROF_TIMER cntEndOverlay("gl-end-overlay");
|
|
|
|
PROF_TIMER cntComposite("gl-composite");
|
|
|
|
PROF_TIMER cntSwap("gl-swap");
|
2016-05-02 13:56:17 +00:00
|
|
|
|
2021-11-28 21:29:06 +00:00
|
|
|
cntTotal.Start();
|
2013-07-23 16:39:07 +00:00
|
|
|
// Cached & non-cached containers are rendered to the same buffer
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( m_mainBuffer );
|
2021-11-28 21:29:06 +00:00
|
|
|
|
|
|
|
cntEndNoncached.Start();
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->EndDrawing();
|
2021-11-28 21:29:06 +00:00
|
|
|
cntEndNoncached.Stop();
|
|
|
|
|
|
|
|
cntEndCached.Start();
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->EndDrawing();
|
2021-11-28 21:29:06 +00:00
|
|
|
cntEndCached.Stop();
|
2013-05-16 16:43:25 +00:00
|
|
|
|
2021-11-28 21:29:06 +00:00
|
|
|
cntEndOverlay.Start();
|
2013-07-23 16:39:07 +00:00
|
|
|
// Overlay container is rendered to a different buffer
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_overlayBuffer )
|
|
|
|
m_compositor->SetBuffer( m_overlayBuffer );
|
|
|
|
|
|
|
|
m_overlayManager->EndDrawing();
|
2021-11-28 21:29:06 +00:00
|
|
|
cntEndOverlay.Stop();
|
2013-07-23 16:39:07 +00:00
|
|
|
|
2021-11-28 21:29:06 +00:00
|
|
|
cntComposite.Start();
|
2013-10-29 16:53:47 +00:00
|
|
|
// Be sure that the framebuffer is not colorized (happens on specific GPU&drivers combinations)
|
|
|
|
glColor4d( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
|
2013-07-23 16:39:07 +00:00
|
|
|
// Draw the remaining contents, blit the rendering targets to the screen, swap the buffers
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->DrawBuffer( m_mainBuffer );
|
2020-06-21 16:14:37 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_overlayBuffer )
|
|
|
|
m_compositor->DrawBuffer( m_overlayBuffer );
|
2020-06-21 16:14:37 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->Present();
|
2017-01-13 16:10:16 +00:00
|
|
|
blitCursor();
|
2013-08-28 15:06:07 +00:00
|
|
|
|
2021-11-28 22:04:41 +00:00
|
|
|
cntComposite.Stop();
|
|
|
|
|
2021-11-28 21:29:06 +00:00
|
|
|
cntSwap.Start();
|
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
|
|
|
SwapBuffers();
|
2021-11-28 21:29:06 +00:00
|
|
|
cntSwap.Stop();
|
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-11-28 21:29:06 +00:00
|
|
|
cntTotal.Stop();
|
|
|
|
|
|
|
|
KI_TRACE( traceGalProfile, "Timing: %s %s %s %s %s %s\n", cntTotal.to_string(),
|
|
|
|
cntEndCached.to_string(), cntEndNoncached.to_string(), cntEndOverlay.to_string(),
|
|
|
|
cntComposite.to_string(), cntSwap.to_string() );
|
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-11-28 15:39:10 +00:00
|
|
|
void OPENGL_GAL::LockContext( int aClientCookie )
|
2018-10-12 22:42:44 +00:00
|
|
|
{
|
2021-01-09 20:13:46 +00:00
|
|
|
wxASSERT_MSG( !m_isContextLocked, "Context already locked." );
|
|
|
|
m_isContextLocked = true;
|
2021-03-19 21:38:53 +00:00
|
|
|
m_lockClientCookie = aClientCookie;
|
2018-10-26 21:25:09 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().LockCtx( m_glPrivContext, this );
|
2018-10-12 22:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-28 15:39:10 +00:00
|
|
|
void OPENGL_GAL::UnlockContext( int aClientCookie )
|
2018-10-12 22:42:44 +00:00
|
|
|
{
|
2021-01-09 20:13:46 +00:00
|
|
|
wxASSERT_MSG( m_isContextLocked, "Context not locked. A GAL_CONTEXT_LOCKER RAII object must "
|
2021-02-16 22:25:27 +00:00
|
|
|
"be stacked rather than making separate lock/unlock calls." );
|
2018-10-26 21:25:09 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
wxASSERT_MSG( m_lockClientCookie == aClientCookie, "Context was locked by a different client. "
|
|
|
|
"Should not be possible with RAII objects." );
|
2018-10-26 21:25:09 +00:00
|
|
|
|
2021-01-09 20:13:46 +00:00
|
|
|
m_isContextLocked = false;
|
2018-10-26 21:25:09 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glPrivContext );
|
2018-10-12 22:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
void OPENGL_GAL::beginUpdate()
|
2016-05-02 14:12:16 +00:00
|
|
|
{
|
2021-01-09 20:13:46 +00:00
|
|
|
wxASSERT_MSG( m_isContextLocked, "GAL_UPDATE_CONTEXT RAII object should have locked context. "
|
2021-02-16 22:25:27 +00:00
|
|
|
"Calling this from anywhere else is not allowed." );
|
2018-10-26 21:25:09 +00:00
|
|
|
|
|
|
|
wxASSERT_MSG( IsVisible(), "GAL::beginUpdate() must not be entered when GAL is not visible. "
|
|
|
|
"Other update routines will expect everything to be initialized "
|
|
|
|
"which will not be the case." );
|
2017-01-13 15:48:23 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_isInitialized )
|
2017-01-13 15:48:23 +00:00
|
|
|
init();
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->Map();
|
2016-05-02 14:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
void OPENGL_GAL::endUpdate()
|
2016-05-02 14:12:16 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_isInitialized )
|
2017-01-13 15:48:23 +00:00
|
|
|
return;
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->Unmap();
|
2016-05-02 14:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint )
|
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-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a );
|
2014-02-25 13:28:09 +00:00
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
drawLineQuad( aStartPoint, aEndPoint );
|
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-05-15 14:48:10 +00:00
|
|
|
void OPENGL_GAL::DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
|
|
|
|
double aWidth )
|
2013-04-17 10:38:00 +00:00
|
|
|
{
|
2020-07-31 13:41:21 +00:00
|
|
|
VECTOR2D startEndVector = aEndPoint - aStartPoint;
|
2021-02-16 22:25:27 +00:00
|
|
|
double lineLength = startEndVector.EuclideanNorm();
|
2020-07-31 13:41:21 +00:00
|
|
|
|
2020-09-21 23:57:25 +00:00
|
|
|
float startx = aStartPoint.x;
|
|
|
|
float starty = aStartPoint.y;
|
|
|
|
float endx = aStartPoint.x + lineLength;
|
|
|
|
float endy = aStartPoint.y + lineLength;
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
// Be careful about floating point rounding. As we draw segments in larger and larger
|
|
|
|
// coordinates, the shader (which uses floats) will lose precision and stop drawing small
|
|
|
|
// segments. In this case, we need to draw a circle for the minimal segment.
|
2020-09-21 23:57:25 +00:00
|
|
|
if( startx == endx || starty == endy )
|
2018-11-15 12:10:42 +00:00
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
DrawCircle( aStartPoint, aWidth / 2 );
|
2018-11-15 12:10:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled || aWidth == 1.0 )
|
2013-04-30 13:59:32 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2013-04-30 13:59:32 +00:00
|
|
|
|
2013-05-15 14:48:10 +00:00
|
|
|
SetLineWidth( aWidth );
|
|
|
|
drawLineQuad( aStartPoint, aEndPoint );
|
2013-04-30 13:59:32 +00:00
|
|
|
}
|
2013-05-15 14:48:10 +00:00
|
|
|
else
|
2013-04-17 10:38:00 +00:00
|
|
|
{
|
2022-01-20 23:08:48 +00:00
|
|
|
EDA_ANGLE lineAngle( startEndVector );
|
2013-06-04 13:58:53 +00:00
|
|
|
// Outlined tracks
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2019-02-17 03:55:58 +00:00
|
|
|
SetLineWidth( 1.0 );
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
|
|
|
m_strokeColor.a );
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2013-05-15 14:48:10 +00:00
|
|
|
Save();
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Translate( aStartPoint.x, aStartPoint.y, 0.0 );
|
2022-01-20 23:08:48 +00:00
|
|
|
m_currentManager->Rotate( lineAngle.AsRadians(), 0.0f, 0.0f, 1.0f );
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
drawLineQuad( VECTOR2D( 0.0, aWidth / 2.0 ), VECTOR2D( lineLength, aWidth / 2.0 ) );
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
drawLineQuad( VECTOR2D( 0.0, -aWidth / 2.0 ), VECTOR2D( lineLength, -aWidth / 2.0 ) );
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2013-07-01 12:39:27 +00:00
|
|
|
// Draw line caps
|
2013-09-16 07:51:53 +00:00
|
|
|
drawStrokedSemiCircle( VECTOR2D( 0.0, 0.0 ), aWidth / 2, M_PI / 2 );
|
|
|
|
drawStrokedSemiCircle( VECTOR2D( lineLength, 0.0 ), aWidth / 2, -M_PI / 2 );
|
2013-04-17 10:38:00 +00:00
|
|
|
|
2013-05-15 14:48:10 +00:00
|
|
|
Restore();
|
2013-04-17 10:38:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
void OPENGL_GAL::DrawCircle( const VECTOR2D& aCenterPoint, double aRadius )
|
2013-06-27 09:54:49 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
2013-06-27 09:54:49 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 3 );
|
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
/* Draw a triangle that contains the circle, then shade it leaving only the circle.
|
2016-05-02 13:56:10 +00:00
|
|
|
* Parameters given to Shader() are indices of the triangle's vertices
|
2013-07-30 16:29:54 +00:00
|
|
|
* (if you want to understand more, check the vertex shader source [shader.vert]).
|
|
|
|
* Shader uses this coordinates to determine if fragments are inside the circle or not.
|
2019-01-21 18:42:06 +00:00
|
|
|
* Does the calculations in the vertex shader now (pixel alignment)
|
2013-07-30 16:29:54 +00:00
|
|
|
* v2
|
|
|
|
* /\
|
|
|
|
* //\\
|
|
|
|
* v0 /_\/_\ v1
|
|
|
|
*/
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FILLED_CIRCLE, 1.0, aRadius );
|
|
|
|
m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FILLED_CIRCLE, 2.0, aRadius );
|
|
|
|
m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FILLED_CIRCLE, 3.0, aRadius );
|
|
|
|
m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, m_layerDepth );
|
2013-06-27 09:54:49 +00:00
|
|
|
}
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 3 );
|
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
|
|
|
m_strokeColor.a );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
/* Draw a triangle that contains the circle, then shade it leaving only the circle.
|
2016-05-02 13:56:10 +00:00
|
|
|
* Parameters given to Shader() are indices of the triangle's vertices
|
2013-07-30 16:29:54 +00:00
|
|
|
* (if you want to understand more, check the vertex shader source [shader.vert]).
|
|
|
|
* and the line width. Shader uses this coordinates to determine if fragments are
|
|
|
|
* inside the circle or not.
|
|
|
|
* v2
|
|
|
|
* /\
|
|
|
|
* //\\
|
|
|
|
* v0 /_\/_\ v1
|
|
|
|
*/
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 1.0, aRadius, m_lineWidth );
|
|
|
|
m_currentManager->Vertex( aCenterPoint.x, // v0
|
2021-03-22 19:34:33 +00:00
|
|
|
aCenterPoint.y, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 2.0, aRadius, m_lineWidth );
|
|
|
|
m_currentManager->Vertex( aCenterPoint.x, // v1
|
2021-03-22 19:34:33 +00:00
|
|
|
aCenterPoint.y, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 3.0, aRadius, m_lineWidth );
|
|
|
|
m_currentManager->Vertex( aCenterPoint.x, aCenterPoint.y, // v2
|
2021-03-22 19:34:33 +00:00
|
|
|
m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
2013-06-27 09:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
|
|
|
|
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle )
|
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-07-30 16:29:54 +00:00
|
|
|
if( aRadius <= 0 )
|
|
|
|
return;
|
2013-06-04 13:58:53 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
double startAngle = aStartAngle.AsRadians();
|
|
|
|
double endAngle = aEndAngle.AsRadians();
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
// Swap the angles, if start angle is greater than end angle
|
2022-01-16 16:15:07 +00:00
|
|
|
SWAP( startAngle, >, endAngle );
|
2013-06-04 13:58:53 +00:00
|
|
|
|
2017-03-10 10:18:15 +00:00
|
|
|
const double alphaIncrement = calcAngleStep( aRadius );
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
Save();
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
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-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
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-07-30 16:29:54 +00:00
|
|
|
double alpha;
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
|
|
|
m_currentManager->Shader( SHADER_NONE );
|
2013-07-01 13:23:43 +00:00
|
|
|
|
2014-08-06 11:51:46 +00:00
|
|
|
// Triangle fan
|
2022-01-16 16:15:07 +00:00
|
|
|
for( alpha = startAngle; ( alpha + alphaIncrement ) < endAngle; )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 3 );
|
|
|
|
m_currentManager->Vertex( 0.0, 0.0, m_layerDepth );
|
2021-03-22 19:34:33 +00:00
|
|
|
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius,
|
|
|
|
m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
alpha += alphaIncrement;
|
2021-03-22 19:34:33 +00:00
|
|
|
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius,
|
|
|
|
m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
2013-07-01 13:23:43 +00:00
|
|
|
|
2014-08-06 11:51:46 +00:00
|
|
|
// The last missing triangle
|
2022-01-16 16:15:07 +00:00
|
|
|
const VECTOR2D endPoint( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
2016-05-02 13:56:10 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 3 );
|
|
|
|
m_currentManager->Vertex( 0.0, 0.0, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( cos( alpha ) * aRadius, sin( alpha ) * aRadius, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( endPoint.x, endPoint.y, m_layerDepth );
|
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
|
|
|
}
|
2018-09-15 07:00:13 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2018-09-15 07:00:13 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
|
|
|
m_strokeColor.a );
|
2018-09-15 07:00:13 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D p( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
|
2021-02-16 22:25:27 +00:00
|
|
|
double alpha;
|
2018-09-15 07:00:13 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
|
2018-09-15 07:00:13 +00:00
|
|
|
{
|
|
|
|
VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
|
|
|
|
DrawLine( p, p_next );
|
|
|
|
|
|
|
|
p = p_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the last missing part
|
2022-01-16 16:15:07 +00:00
|
|
|
if( alpha != endAngle )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D p_last( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
2019-02-21 18:14:43 +00:00
|
|
|
DrawLine( p, p_last );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-06 14:36:28 +00:00
|
|
|
void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
|
2022-01-16 16:15:07 +00:00
|
|
|
const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle,
|
2021-09-06 14:36:28 +00:00
|
|
|
double aWidth, double aMaxError )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
|
|
|
if( aRadius <= 0 )
|
|
|
|
{
|
|
|
|
// Arcs of zero radius are a circle of aWidth diameter
|
|
|
|
if( aWidth > 0 )
|
|
|
|
DrawCircle( aCenterPoint, aWidth / 2.0 );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
double startAngle = aStartAngle.AsRadians();
|
|
|
|
double endAngle = aEndAngle.AsRadians();
|
|
|
|
|
2019-02-21 18:14:43 +00:00
|
|
|
// Swap the angles, if start angle is greater than end angle
|
2022-01-16 16:15:07 +00:00
|
|
|
SWAP( startAngle, >, endAngle );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2021-09-06 14:36:28 +00:00
|
|
|
// Calculate the seg count to approximate the arc with aMaxError or less
|
2022-01-14 15:34:41 +00:00
|
|
|
int segCount360 = GetArcToSegmentCount( aRadius, aMaxError, FULL_CIRCLE );
|
2021-09-06 16:34:41 +00:00
|
|
|
segCount360 = std::max( SEG_PER_CIRCLE_COUNT, segCount360 );
|
2021-09-06 14:36:28 +00:00
|
|
|
double alphaIncrement = 2.0 * M_PI / segCount360;
|
2020-10-24 15:26:44 +00:00
|
|
|
|
|
|
|
// Refinement: Use a segment count multiple of 2, because we have a control point
|
|
|
|
// on the middle of the arc, and the look is better if it is on a segment junction
|
|
|
|
// because there is no approx error
|
2022-01-16 16:15:07 +00:00
|
|
|
int seg_count = KiROUND( ( endAngle - startAngle ) / alphaIncrement );
|
2020-10-24 15:26:44 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
if( seg_count % 2 != 0 )
|
2020-10-24 15:26:44 +00:00
|
|
|
seg_count += 1;
|
|
|
|
|
|
|
|
// Recalculate alphaIncrement with a even integer number of segment
|
2020-10-26 18:43:43 +00:00
|
|
|
if( seg_count )
|
2022-01-16 16:15:07 +00:00
|
|
|
alphaIncrement = ( endAngle - startAngle ) / seg_count;
|
2020-10-23 12:42:48 +00:00
|
|
|
|
2019-02-21 18:14:43 +00:00
|
|
|
Save();
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
|
|
|
m_strokeColor.a );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
double width = aWidth / 2.0;
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D startPoint( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
|
|
|
|
VECTOR2D endPoint( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
drawStrokedSemiCircle( startPoint, width, startAngle + M_PI );
|
|
|
|
drawStrokedSemiCircle( endPoint, width, endAngle );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D pOuter( cos( startAngle ) * ( aRadius + width ),
|
|
|
|
sin( startAngle ) * ( aRadius + width ) );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D pInner( cos( startAngle ) * ( aRadius - width ),
|
|
|
|
sin( startAngle ) * ( aRadius - width ) );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
|
|
|
double alpha;
|
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
|
|
|
VECTOR2D pNextOuter( cos( alpha ) * ( aRadius + width ),
|
|
|
|
sin( alpha ) * ( aRadius + width ) );
|
|
|
|
VECTOR2D pNextInner( cos( alpha ) * ( aRadius - width ),
|
|
|
|
sin( alpha ) * ( aRadius - width ) );
|
|
|
|
|
|
|
|
DrawLine( pOuter, pNextOuter );
|
|
|
|
DrawLine( pInner, pNextInner );
|
|
|
|
|
|
|
|
pOuter = pNextOuter;
|
|
|
|
pInner = pNextInner;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the last missing part
|
2022-01-16 16:15:07 +00:00
|
|
|
if( alpha != endAngle )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D pLastOuter( cos( endAngle ) * ( aRadius + width ),
|
|
|
|
sin( endAngle ) * ( aRadius + width ) );
|
|
|
|
VECTOR2D pLastInner( cos( endAngle ) * ( aRadius - width ),
|
|
|
|
sin( endAngle ) * ( aRadius - width ) );
|
2019-02-21 18:14:43 +00:00
|
|
|
|
|
|
|
DrawLine( pOuter, pLastOuter );
|
|
|
|
DrawLine( pInner, pLastInner );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2019-02-21 18:14:43 +00:00
|
|
|
SetLineWidth( aWidth );
|
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D p( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
|
2021-02-16 22:25:27 +00:00
|
|
|
double alpha;
|
2019-02-21 18:14:43 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
|
2019-02-21 18:14:43 +00:00
|
|
|
{
|
|
|
|
VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
|
|
|
|
DrawLine( p, p_next );
|
|
|
|
|
|
|
|
p = p_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the last missing part
|
2022-01-16 16:15:07 +00:00
|
|
|
if( alpha != endAngle )
|
2018-09-15 07:00:13 +00:00
|
|
|
{
|
2022-01-16 16:15:07 +00:00
|
|
|
VECTOR2D p_last( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
|
2018-09-15 07:00:13 +00:00
|
|
|
DrawLine( p, p_last );
|
|
|
|
}
|
|
|
|
}
|
2013-07-01 13:23:43 +00:00
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
Restore();
|
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-04-17 10:48:37 +00:00
|
|
|
void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint )
|
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
|
|
|
{
|
|
|
|
// Compute the diagonal points of the rectangle
|
|
|
|
VECTOR2D diagonalPointA( aEndPoint.x, aStartPoint.y );
|
|
|
|
VECTOR2D diagonalPointB( aStartPoint.x, aEndPoint.y );
|
|
|
|
|
|
|
|
// Fill the rectangle
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
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-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 6 );
|
|
|
|
m_currentManager->Shader( SHADER_NONE );
|
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2013-04-25 16:30:53 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Vertex( aStartPoint.x, aStartPoint.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( diagonalPointA.x, diagonalPointA.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( aEndPoint.x, aEndPoint.y, m_layerDepth );
|
2013-05-15 14:48:10 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Vertex( aStartPoint.x, aStartPoint.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( aEndPoint.x, aEndPoint.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( diagonalPointB.x, diagonalPointB.y, m_layerDepth );
|
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
|
|
|
}
|
2018-09-07 10:20:42 +00:00
|
|
|
|
|
|
|
// Stroke the outline
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2018-09-07 10:20:42 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
|
|
|
m_strokeColor.a );
|
2018-09-07 10:20:42 +00:00
|
|
|
|
|
|
|
std::deque<VECTOR2D> pointList;
|
|
|
|
pointList.push_back( aStartPoint );
|
|
|
|
pointList.push_back( diagonalPointA );
|
|
|
|
pointList.push_back( aEndPoint );
|
|
|
|
pointList.push_back( diagonalPointB );
|
|
|
|
pointList.push_back( aStartPoint );
|
|
|
|
DrawPolyline( pointList );
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-20 14:16:39 +00:00
|
|
|
void OPENGL_GAL::DrawPolyline( const std::deque<VECTOR2D>& aPointList )
|
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-02-16 22:25:27 +00:00
|
|
|
drawPolyline(
|
|
|
|
[&]( int idx )
|
|
|
|
{
|
|
|
|
return aPointList[idx];
|
|
|
|
},
|
|
|
|
aPointList.size() );
|
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-31 14:07:24 +00:00
|
|
|
void OPENGL_GAL::DrawPolyline( const std::vector<VECTOR2D>& aPointList )
|
|
|
|
{
|
|
|
|
drawPolyline(
|
|
|
|
[&]( int idx )
|
|
|
|
{
|
|
|
|
return aPointList[idx];
|
|
|
|
},
|
|
|
|
aPointList.size() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-20 14:16:39 +00:00
|
|
|
void OPENGL_GAL::DrawPolyline( const VECTOR2D aPointList[], int aListSize )
|
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
drawPolyline(
|
|
|
|
[&]( int idx )
|
|
|
|
{
|
|
|
|
return aPointList[idx];
|
|
|
|
},
|
|
|
|
aListSize );
|
2017-01-24 13:31:57 +00:00
|
|
|
}
|
2016-01-20 14:16:39 +00:00
|
|
|
|
|
|
|
|
2017-01-24 13:31:57 +00:00
|
|
|
void OPENGL_GAL::DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain )
|
|
|
|
{
|
2017-03-07 11:17:59 +00:00
|
|
|
auto numPoints = aLineChain.PointCount();
|
|
|
|
|
|
|
|
if( aLineChain.IsClosed() )
|
|
|
|
numPoints += 1;
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
drawPolyline(
|
|
|
|
[&]( int idx )
|
|
|
|
{
|
|
|
|
return aLineChain.CPoint( idx );
|
|
|
|
},
|
|
|
|
numPoints );
|
2016-01-20 14:16:39 +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
|
|
|
void OPENGL_GAL::DrawPolygon( const std::deque<VECTOR2D>& aPointList )
|
|
|
|
{
|
2020-08-21 22:40:36 +00:00
|
|
|
wxCHECK( aPointList.size() >= 2, /* void */ );
|
2021-02-16 22:25:27 +00:00
|
|
|
auto points = std::unique_ptr<GLdouble[]>( new GLdouble[3 * aPointList.size()] );
|
2017-01-24 13:31:57 +00:00
|
|
|
GLdouble* ptr = points.get();
|
2013-06-04 13:58:53 +00:00
|
|
|
|
2017-01-24 13:31:57 +00:00
|
|
|
for( const VECTOR2D& p : aPointList )
|
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
|
|
|
{
|
2017-01-24 13:31:57 +00:00
|
|
|
*ptr++ = p.x;
|
|
|
|
*ptr++ = p.y;
|
2021-03-19 21:38:53 +00:00
|
|
|
*ptr++ = m_layerDepth;
|
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
|
|
|
}
|
|
|
|
|
2017-01-24 13:31:57 +00:00
|
|
|
drawPolygon( points.get(), aPointList.size() );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-20 14:16:39 +00:00
|
|
|
void OPENGL_GAL::DrawPolygon( const VECTOR2D aPointList[], int aListSize )
|
|
|
|
{
|
2020-08-21 22:40:36 +00:00
|
|
|
wxCHECK( aListSize >= 2, /* void */ );
|
2021-02-16 22:25:27 +00:00
|
|
|
auto points = std::unique_ptr<GLdouble[]>( new GLdouble[3 * aListSize] );
|
|
|
|
GLdouble* target = points.get();
|
2017-01-24 13:31:57 +00:00
|
|
|
const VECTOR2D* src = aPointList;
|
2016-01-20 14:16:39 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < aListSize; ++i )
|
|
|
|
{
|
2017-01-24 13:31:57 +00:00
|
|
|
*target++ = src->x;
|
|
|
|
*target++ = src->y;
|
2021-03-19 21:38:53 +00:00
|
|
|
*target++ = m_layerDepth;
|
2017-01-24 13:31:57 +00:00
|
|
|
++src;
|
2016-01-20 14:16:39 +00:00
|
|
|
}
|
|
|
|
|
2017-01-24 13:31:57 +00:00
|
|
|
drawPolygon( points.get(), aListSize );
|
|
|
|
}
|
2016-01-20 14:16:39 +00:00
|
|
|
|
2018-06-22 23:35:07 +00:00
|
|
|
|
2021-07-26 17:56:11 +00:00
|
|
|
void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet,
|
|
|
|
bool aStrokeTriangulation )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_NONE );
|
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2017-11-23 16:20:27 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2018-06-23 00:02:49 +00:00
|
|
|
for( unsigned int j = 0; j < aPolySet.TriangulatedPolyCount(); ++j )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
|
|
|
auto triPoly = aPolySet.TriangulatedPolygon( j );
|
|
|
|
|
2018-07-13 04:52:21 +00:00
|
|
|
for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
|
|
|
VECTOR2I a, b, c;
|
2018-07-13 04:52:21 +00:00
|
|
|
triPoly->GetTriangle( i, a, b, c );
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Vertex( a.x, a.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( b.x, b.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( c.x, c.y, m_layerDepth );
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
|
|
|
for( int j = 0; j < aPolySet.OutlineCount(); ++j )
|
|
|
|
{
|
|
|
|
const auto& poly = aPolySet.Polygon( j );
|
|
|
|
|
|
|
|
for( const auto& lc : poly )
|
|
|
|
{
|
|
|
|
DrawPolyline( lc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-12 13:16:57 +00:00
|
|
|
|
|
|
|
if( ADVANCED_CFG::GetCfg().m_DrawTriangulationOutlines )
|
2021-07-26 17:56:11 +00:00
|
|
|
{
|
|
|
|
aStrokeTriangulation = true;
|
|
|
|
SetStrokeColor( COLOR4D( 0.0, 1.0, 0.2, 1.0 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aStrokeTriangulation )
|
2020-08-12 13:16:57 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
COLOR4D oldStrokeColor = m_strokeColor;
|
|
|
|
double oldLayerDepth = m_layerDepth;
|
2020-08-12 13:16:57 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
SetLayerDepth( m_layerDepth - 1 );
|
2020-08-12 13:16:57 +00:00
|
|
|
|
|
|
|
for( unsigned int j = 0; j < aPolySet.TriangulatedPolyCount(); ++j )
|
|
|
|
{
|
|
|
|
auto triPoly = aPolySet.TriangulatedPolygon( j );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
|
|
|
|
{
|
|
|
|
VECTOR2I a, b, c;
|
|
|
|
triPoly->GetTriangle( i, a, b, c );
|
|
|
|
DrawLine( a, b );
|
|
|
|
DrawLine( b, c );
|
|
|
|
DrawLine( c, a );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetStrokeColor( oldStrokeColor );
|
|
|
|
SetLayerDepth( oldLayerDepth );
|
|
|
|
}
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|
|
|
|
|
2016-01-20 14:16:39 +00:00
|
|
|
|
2021-07-26 17:56:11 +00:00
|
|
|
void OPENGL_GAL::DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation )
|
2017-01-24 13:31:57 +00:00
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
if( aPolySet.IsTriangulationUpToDate() )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
2021-07-26 17:56:11 +00:00
|
|
|
drawTriangulatedPolyset( aPolySet, aStrokeTriangulation );
|
2017-11-23 16:20:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-24 13:31:57 +00:00
|
|
|
for( int j = 0; j < aPolySet.OutlineCount(); ++j )
|
|
|
|
{
|
|
|
|
const SHAPE_LINE_CHAIN& outline = aPolySet.COutline( j );
|
2018-12-19 18:53:27 +00:00
|
|
|
DrawPolygon( outline );
|
|
|
|
}
|
|
|
|
}
|
2017-12-21 08:49:55 +00:00
|
|
|
|
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
void OPENGL_GAL::DrawPolygon( const SHAPE_LINE_CHAIN& aPolygon )
|
|
|
|
{
|
2020-08-21 22:40:36 +00:00
|
|
|
wxCHECK( aPolygon.PointCount() >= 2, /* void */ );
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
const int pointCount = aPolygon.SegmentCount() + 1;
|
2018-12-19 18:53:27 +00:00
|
|
|
std::unique_ptr<GLdouble[]> points( new GLdouble[3 * pointCount] );
|
2021-02-16 22:25:27 +00:00
|
|
|
GLdouble* ptr = points.get();
|
2018-12-19 18:53:27 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < pointCount; ++i )
|
|
|
|
{
|
|
|
|
const VECTOR2I& p = aPolygon.CPoint( i );
|
|
|
|
*ptr++ = p.x;
|
|
|
|
*ptr++ = p.y;
|
2021-03-19 21:38:53 +00:00
|
|
|
*ptr++ = m_layerDepth;
|
2017-01-24 13:31:57 +00:00
|
|
|
}
|
2018-12-19 18:53:27 +00:00
|
|
|
|
|
|
|
drawPolygon( points.get(), pointCount );
|
2016-01-20 14:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-17 10:48:37 +00:00
|
|
|
void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aControlPointA,
|
2019-11-09 10:37:49 +00:00
|
|
|
const VECTOR2D& aControlPointB, const VECTOR2D& aEndPoint,
|
|
|
|
double aFilterValue )
|
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
|
|
|
{
|
2019-11-09 10:14:20 +00:00
|
|
|
std::vector<VECTOR2D> output;
|
|
|
|
std::vector<VECTOR2D> pointCtrl;
|
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
|
|
|
|
2019-11-09 10:14:20 +00:00
|
|
|
pointCtrl.push_back( aStartPoint );
|
|
|
|
pointCtrl.push_back( aControlPointA );
|
|
|
|
pointCtrl.push_back( aControlPointB );
|
|
|
|
pointCtrl.push_back( aEndPoint );
|
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
|
|
|
|
2019-11-09 10:14:20 +00:00
|
|
|
BEZIER_POLY converter( pointCtrl );
|
2019-11-09 10:37:49 +00:00
|
|
|
converter.GetPoly( output, aFilterValue );
|
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
|
|
|
|
2019-11-09 10:14:20 +00:00
|
|
|
DrawPolyline( &output[0], output.size() );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-06 16:59:16 +00:00
|
|
|
void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
|
|
|
|
{
|
2018-09-10 13:37:28 +00:00
|
|
|
// We have to calculate the pixel size in users units to draw the image.
|
2021-03-19 21:38:53 +00:00
|
|
|
// m_worldUnitLength is a factor used for converting IU to inches
|
|
|
|
double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength );
|
2018-10-21 22:16:15 +00:00
|
|
|
double w = (double) aBitmap.GetSizePixels().x * scale;
|
|
|
|
double h = (double) aBitmap.GetSizePixels().y * scale;
|
2018-07-30 14:18:53 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
auto xform = m_currentManager->GetTransformation();
|
2018-06-06 16:59:16 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
glm::vec4 v0 = xform * glm::vec4( -w / 2, -h / 2, 0.0, 0.0 );
|
|
|
|
glm::vec4 v1 = xform * glm::vec4( w / 2, h / 2, 0.0, 0.0 );
|
2018-07-29 22:11:47 +00:00
|
|
|
glm::vec4 trans = xform[3];
|
2018-09-07 16:13:20 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
auto texture_id = m_bitmapCache->RequestBitmap( &aBitmap );
|
2018-12-30 19:30:43 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
if( !glIsTexture( texture_id ) ) // ensure the bitmap texture is still valid
|
2018-12-30 19:30:43 +00:00
|
|
|
return;
|
2018-06-06 16:59:16 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
auto oldTarget = GetTarget();
|
2018-06-06 16:59:16 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
glPushMatrix();
|
|
|
|
glTranslated( trans.x, trans.y, trans.z );
|
2018-06-06 16:59:16 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
SetTarget( TARGET_NONCACHED );
|
2021-02-16 22:25:27 +00:00
|
|
|
glEnable( GL_TEXTURE_2D );
|
2018-07-29 22:11:47 +00:00
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
2018-12-30 19:30:43 +00:00
|
|
|
glBindTexture( GL_TEXTURE_2D, texture_id );
|
2018-07-30 14:18:53 +00:00
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
glBegin( GL_QUADS );
|
2018-10-21 22:16:15 +00:00
|
|
|
glColor4f( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
glTexCoord2f( 0.0, 0.0 );
|
2021-03-19 21:38:53 +00:00
|
|
|
glVertex3f( v0.x, v0.y, m_layerDepth );
|
2018-10-21 22:16:15 +00:00
|
|
|
glColor4f( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
glTexCoord2f( 1.0, 0.0 );
|
2021-03-19 21:38:53 +00:00
|
|
|
glVertex3f( v1.x, v0.y, m_layerDepth );
|
2018-10-21 22:16:15 +00:00
|
|
|
glColor4f( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
glTexCoord2f( 1.0, 1.0 );
|
2021-03-19 21:38:53 +00:00
|
|
|
glVertex3f( v1.x, v1.y, m_layerDepth );
|
2018-10-21 22:16:15 +00:00
|
|
|
glColor4f( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
glTexCoord2f( 0.0, 1.0 );
|
2021-03-19 21:38:53 +00:00
|
|
|
glVertex3f( v0.x, v1.y, m_layerDepth );
|
2018-07-29 22:11:47 +00:00
|
|
|
glEnd();
|
|
|
|
|
|
|
|
SetTarget( oldTarget );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
2018-07-30 14:18:53 +00:00
|
|
|
|
2018-12-30 19:30:43 +00:00
|
|
|
#ifdef DISABLE_BITMAP_CACHE
|
|
|
|
glDeleteTextures( 1, &texture_id );
|
|
|
|
#endif
|
|
|
|
|
2018-07-29 22:11:47 +00:00
|
|
|
glPopMatrix();
|
2018-06-06 16:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-11 13:47:21 +00:00
|
|
|
void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition,
|
|
|
|
const EDA_ANGLE& aAngle )
|
2016-05-02 14:04:45 +00:00
|
|
|
{
|
2021-02-07 13:10:30 +00:00
|
|
|
// Fallback to generic impl (which uses the stroke font) on cases we don't handle
|
2022-03-06 16:59:18 +00:00
|
|
|
if( IsTextMirrored()
|
|
|
|
|| aText.Contains( wxT( "^{" ) )
|
|
|
|
|| aText.Contains( wxT( "_{" ) )
|
|
|
|
|| aText.Contains( wxT( "\n" ) ) )
|
|
|
|
{
|
2022-01-11 13:47:21 +00:00
|
|
|
return GAL::BitmapText( aText, aPosition, aAngle );
|
2022-03-06 16:59:18 +00:00
|
|
|
}
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2021-06-12 10:49:12 +00:00
|
|
|
const UTF8 text( aText );
|
|
|
|
VECTOR2D textSize;
|
|
|
|
float commonOffset;
|
2017-12-07 16:20:20 +00:00
|
|
|
std::tie( textSize, commonOffset ) = computeBitmapTextSize( text );
|
2016-10-20 12:29:51 +00:00
|
|
|
|
2018-01-08 09:46:27 +00:00
|
|
|
const double SCALE = 1.4 * GetGlyphSize().y / textSize.y;
|
2021-06-12 10:49:12 +00:00
|
|
|
int overbarLength = 0;
|
|
|
|
double overbarHeight = textSize.y;
|
2016-05-02 14:04:45 +00:00
|
|
|
|
|
|
|
Save();
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a );
|
|
|
|
m_currentManager->Translate( aPosition.x, aPosition.y, m_layerDepth );
|
2022-01-11 13:47:21 +00:00
|
|
|
m_currentManager->Rotate( aAngle.AsRadians(), 0.0f, 0.0f, -1.0f );
|
2016-12-02 17:59:48 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
double sx = SCALE * ( m_globalFlipX ? -1.0 : 1.0 );
|
|
|
|
double sy = SCALE * ( m_globalFlipY ? -1.0 : 1.0 );
|
2016-12-02 17:59:48 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Scale( sx, sy, 0 );
|
|
|
|
m_currentManager->Translate( 0, -commonOffset, 0 );
|
2016-05-02 14:04:45 +00:00
|
|
|
|
|
|
|
switch( GetHorizontalJustify() )
|
|
|
|
{
|
2021-12-28 22:13:54 +00:00
|
|
|
case GR_TEXT_H_ALIGN_CENTER:
|
2021-03-22 19:34:33 +00:00
|
|
|
Translate( VECTOR2D( -textSize.x / 2.0, 0 ) );
|
|
|
|
break;
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
case GR_TEXT_H_ALIGN_RIGHT:
|
2016-05-02 14:04:45 +00:00
|
|
|
//if( !IsTextMirrored() )
|
2021-02-16 22:25:27 +00:00
|
|
|
Translate( VECTOR2D( -textSize.x, 0 ) );
|
2016-05-02 14:04:45 +00:00
|
|
|
break;
|
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
case GR_TEXT_H_ALIGN_LEFT:
|
2016-05-02 14:04:45 +00:00
|
|
|
//if( IsTextMirrored() )
|
2021-02-16 22:25:27 +00:00
|
|
|
//Translate( VECTOR2D( -textSize.x, 0 ) );
|
2016-05-02 14:04:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( GetVerticalJustify() )
|
|
|
|
{
|
2021-12-28 22:13:54 +00:00
|
|
|
case GR_TEXT_V_ALIGN_TOP:
|
2016-05-02 14:04:45 +00:00
|
|
|
break;
|
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
case GR_TEXT_V_ALIGN_CENTER:
|
2016-05-02 14:04:45 +00:00
|
|
|
Translate( VECTOR2D( 0, -textSize.y / 2.0 ) );
|
2016-05-03 09:58:48 +00:00
|
|
|
overbarHeight = 0;
|
2016-05-02 14:04:45 +00:00
|
|
|
break;
|
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
case GR_TEXT_V_ALIGN_BOTTOM:
|
2022-02-24 18:15:47 +00:00
|
|
|
Translate( VECTOR2D( 0, -textSize.y ) );
|
|
|
|
overbarHeight = -textSize.y / 2.0;
|
2021-03-22 19:34:33 +00:00
|
|
|
break;
|
2016-05-02 14:04:45 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 13:52:58 +00:00
|
|
|
int overbarDepth = -1;
|
|
|
|
int braceNesting = 0;
|
2017-12-07 16:20:20 +00:00
|
|
|
|
|
|
|
for( UTF8::uni_iter chIt = text.ubegin(), end = text.uend(); chIt < end; ++chIt )
|
2016-05-02 14:04:45 +00:00
|
|
|
{
|
2022-01-11 13:47:21 +00:00
|
|
|
wxASSERT_MSG( *chIt != '\n' && *chIt != '\r', "No support for multiline bitmap text yet" );
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2021-06-05 13:52:58 +00:00
|
|
|
if( *chIt == '~' && overbarDepth == -1 )
|
2016-05-02 14:12:18 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
UTF8::uni_iter lookahead = chIt;
|
2019-10-21 18:03:54 +00:00
|
|
|
|
2021-06-05 13:52:58 +00:00
|
|
|
if( ++lookahead != end && *lookahead == '{' )
|
2019-10-21 18:03:54 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
chIt = lookahead;
|
|
|
|
overbarDepth = braceNesting;
|
|
|
|
braceNesting++;
|
|
|
|
continue;
|
2019-10-21 18:03:54 +00:00
|
|
|
}
|
2016-05-02 14:12:18 +00:00
|
|
|
}
|
2021-06-05 13:52:58 +00:00
|
|
|
else if( *chIt == '{' )
|
2020-12-10 18:38:06 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
braceNesting++;
|
|
|
|
}
|
|
|
|
else if( *chIt == '}' )
|
|
|
|
{
|
|
|
|
if( braceNesting > 0 )
|
|
|
|
braceNesting--;
|
|
|
|
|
|
|
|
if( braceNesting == overbarDepth )
|
|
|
|
{
|
2021-06-13 22:17:56 +00:00
|
|
|
drawBitmapOverbar( overbarLength, overbarHeight );
|
|
|
|
overbarLength = 0;
|
|
|
|
|
2021-06-05 13:52:58 +00:00
|
|
|
overbarDepth = -1;
|
|
|
|
continue;
|
|
|
|
}
|
2020-12-10 18:38:06 +00:00
|
|
|
}
|
2019-10-21 18:03:54 +00:00
|
|
|
|
2021-06-13 22:17:56 +00:00
|
|
|
if( overbarDepth != -1 )
|
2021-06-05 13:52:58 +00:00
|
|
|
overbarLength += drawBitmapChar( *chIt );
|
2017-12-07 16:20:20 +00:00
|
|
|
else
|
2021-06-05 13:52:58 +00:00
|
|
|
drawBitmapChar( *chIt );
|
2016-05-02 14:04:45 +00:00
|
|
|
}
|
|
|
|
|
2016-05-02 14:12:18 +00:00
|
|
|
// Handle the case when overbar is active till the end of the drawn text
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Translate( 0, commonOffset, 0 );
|
2016-10-20 12:29:51 +00:00
|
|
|
|
2021-06-13 22:17:56 +00:00
|
|
|
if( overbarDepth != -1 && overbarLength > 0 )
|
2016-05-02 14:12:18 +00:00
|
|
|
drawBitmapOverbar( overbarLength, overbarHeight );
|
|
|
|
|
2016-05-02 14:04:45 +00:00
|
|
|
Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-02 14:15:24 +00:00
|
|
|
void OPENGL_GAL::DrawGrid()
|
|
|
|
{
|
2017-04-29 09:43:02 +00:00
|
|
|
SetTarget( TARGET_NONCACHED );
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( m_mainBuffer );
|
2016-05-02 14:15:24 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->EnableDepthTest( false );
|
2018-10-14 22:09:59 +00:00
|
|
|
|
2017-02-14 15:31:21 +00:00
|
|
|
// sub-pixel lines all render the same
|
2021-03-19 21:38:53 +00:00
|
|
|
float minorLineWidth = std::fmax( 1.0f,
|
|
|
|
m_gridLineWidth ) * getWorldPixelSize() / GetScaleFactor();
|
2018-09-28 10:46:20 +00:00
|
|
|
float majorLineWidth = minorLineWidth * 2.0f;
|
2017-02-14 15:31:21 +00:00
|
|
|
|
2017-04-29 09:43:02 +00:00
|
|
|
// Draw the axis and grid
|
2016-05-02 14:15:24 +00:00
|
|
|
// For the drawing the start points, end points and increments have
|
|
|
|
// to be calculated in world coordinates
|
2021-03-19 21:38:53 +00:00
|
|
|
VECTOR2D worldStartPoint = m_screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
|
|
|
|
VECTOR2D worldEndPoint = m_screenWorldMatrix * VECTOR2D( m_screenSize );
|
2016-05-02 14:15:24 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Draw axes if desired
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_axesEnabled )
|
2017-03-08 09:35:51 +00:00
|
|
|
{
|
2018-10-12 17:08:25 +00:00
|
|
|
SetLineWidth( minorLineWidth );
|
2021-03-19 21:38:53 +00:00
|
|
|
SetStrokeColor( m_axesColor );
|
2018-10-12 17:08:25 +00:00
|
|
|
|
|
|
|
DrawLine( VECTOR2D( worldStartPoint.x, 0 ), VECTOR2D( worldEndPoint.x, 0 ) );
|
|
|
|
DrawLine( VECTOR2D( 0, worldStartPoint.y ), VECTOR2D( 0, worldEndPoint.y ) );
|
2017-03-08 09:35:51 +00:00
|
|
|
}
|
|
|
|
|
2018-10-12 17:08:25 +00:00
|
|
|
// force flush
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->EndDrawing();
|
2018-10-12 17:08:25 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_gridVisibility || m_gridSize.x == 0 || m_gridSize.y == 0 )
|
2017-03-08 09:35:51 +00:00
|
|
|
return;
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
VECTOR2D gridScreenSize( m_gridSize );
|
2017-04-29 09:43:02 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
double gridThreshold = computeMinGridSpacing() / m_worldScale;
|
2017-04-29 09:43:02 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_gridStyle == GRID_STYLE::SMALL_CROSS )
|
2019-02-21 13:40:09 +00:00
|
|
|
gridThreshold *= 2.0;
|
|
|
|
|
|
|
|
// If we cannot display the grid density, scale down by a tick size and
|
|
|
|
// try again. Eventually, we get some representation of the grid
|
2021-02-16 22:25:27 +00:00
|
|
|
while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold )
|
2019-02-21 13:40:09 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
gridScreenSize = gridScreenSize * static_cast<double>( m_gridTick );
|
2019-02-21 13:40:09 +00:00
|
|
|
}
|
2017-04-29 09:43:02 +00:00
|
|
|
|
2019-05-27 01:29:01 +00:00
|
|
|
// Compute grid starting and ending indexes to draw grid points on the
|
2017-07-14 18:18:37 +00:00
|
|
|
// visible screen area
|
2021-03-19 21:38:53 +00:00
|
|
|
// Note: later any point coordinate will be offsetted by m_gridOrigin
|
|
|
|
int gridStartX = KiROUND( ( worldStartPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
|
|
|
|
int gridEndX = KiROUND( ( worldEndPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
|
|
|
|
int gridStartY = KiROUND( ( worldStartPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
|
|
|
|
int gridEndY = KiROUND( ( worldEndPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
|
2016-05-02 14:15:24 +00:00
|
|
|
|
2017-07-14 18:18:37 +00:00
|
|
|
// Ensure start coordinate > end coordinate
|
2019-03-01 10:09:40 +00:00
|
|
|
SWAP( gridStartX, >, gridEndX );
|
2019-02-21 13:40:09 +00:00
|
|
|
SWAP( gridStartY, >, gridEndY );
|
2016-12-07 09:20:31 +00:00
|
|
|
|
2017-12-20 08:27:40 +00:00
|
|
|
// Ensure the grid fills the screen
|
2021-02-16 22:25:27 +00:00
|
|
|
--gridStartX;
|
|
|
|
++gridEndX;
|
|
|
|
--gridStartY;
|
|
|
|
++gridEndY;
|
2017-12-20 08:27:40 +00:00
|
|
|
|
2016-05-02 14:15:24 +00:00
|
|
|
glDisable( GL_DEPTH_TEST );
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_gridStyle == GRID_STYLE::DOTS )
|
2016-05-02 14:15:24 +00:00
|
|
|
{
|
|
|
|
glEnable( GL_STENCIL_TEST );
|
|
|
|
glStencilFunc( GL_ALWAYS, 1, 1 );
|
|
|
|
glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
|
|
|
|
glColor4d( 0.0, 0.0, 0.0, 0.0 );
|
2018-10-13 11:39:09 +00:00
|
|
|
SetStrokeColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
|
2016-05-02 14:15:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
glColor4d( m_gridColor.r, m_gridColor.g, m_gridColor.b, m_gridColor.a );
|
|
|
|
SetStrokeColor( m_gridColor );
|
2016-05-02 14:15:24 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_gridStyle == GRID_STYLE::SMALL_CROSS )
|
2016-05-02 14:15:24 +00:00
|
|
|
{
|
2017-03-01 09:29:19 +00:00
|
|
|
// Vertical positions
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
2016-05-02 14:15:24 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
bool tickY = ( j % m_gridTick == 0 );
|
|
|
|
const double posY = j * gridScreenSize.y + m_gridOrigin.y;
|
2019-02-21 13:40:09 +00:00
|
|
|
|
|
|
|
// Horizontal positions
|
|
|
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
2017-03-01 09:29:19 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
bool tickX = ( i % m_gridTick == 0 );
|
2019-02-21 13:40:09 +00:00
|
|
|
SetLineWidth( ( ( tickX && tickY ) ? majorLineWidth : minorLineWidth ) );
|
|
|
|
auto lineLen = 2.0 * GetLineWidth();
|
2021-03-19 21:38:53 +00:00
|
|
|
auto posX = i * gridScreenSize.x + m_gridOrigin.x;
|
2019-02-21 13:40:09 +00:00
|
|
|
|
|
|
|
DrawLine( VECTOR2D( posX - lineLen, posY ), VECTOR2D( posX + lineLen, posY ) );
|
|
|
|
DrawLine( VECTOR2D( posX, posY - lineLen ), VECTOR2D( posX, posY + lineLen ) );
|
2017-03-01 09:29:19 +00:00
|
|
|
}
|
2016-05-02 14:15:24 +00:00
|
|
|
}
|
2018-10-12 21:52:16 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->EndDrawing();
|
2016-05-02 14:15:24 +00:00
|
|
|
}
|
2017-03-01 09:29:19 +00:00
|
|
|
else
|
2016-05-02 14:15:24 +00:00
|
|
|
{
|
2017-03-01 09:29:19 +00:00
|
|
|
// Vertical lines
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
2017-03-01 09:29:19 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
const double y = j * gridScreenSize.y + m_gridOrigin.y;
|
2017-03-08 09:35:51 +00:00
|
|
|
|
|
|
|
// If axes are drawn, skip the lines that would cover them
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_axesEnabled && y == 0.0 )
|
2017-03-08 09:35:51 +00:00
|
|
|
continue;
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
SetLineWidth( ( j % m_gridTick == 0 ) ? majorLineWidth : minorLineWidth );
|
|
|
|
VECTOR2D a( gridStartX * gridScreenSize.x + m_gridOrigin.x, y );
|
|
|
|
VECTOR2D b( gridEndX * gridScreenSize.x + m_gridOrigin.x, y );
|
2016-05-02 14:15:24 +00:00
|
|
|
|
2019-02-21 13:40:09 +00:00
|
|
|
DrawLine( a, b );
|
2017-03-01 09:29:19 +00:00
|
|
|
}
|
2016-05-02 14:15:24 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->EndDrawing();
|
2018-10-12 17:08:25 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_gridStyle == GRID_STYLE::DOTS )
|
2016-05-02 14:15:24 +00:00
|
|
|
{
|
2017-03-01 09:29:19 +00:00
|
|
|
glStencilFunc( GL_NOTEQUAL, 0, 1 );
|
2021-03-19 21:38:53 +00:00
|
|
|
glColor4d( m_gridColor.r, m_gridColor.g, m_gridColor.b, m_gridColor.a );
|
|
|
|
SetStrokeColor( m_gridColor );
|
2016-05-02 14:15:24 +00:00
|
|
|
}
|
|
|
|
|
2017-03-01 09:29:19 +00:00
|
|
|
// Horizontal lines
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
2017-03-01 09:29:19 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
const double x = i * gridScreenSize.x + m_gridOrigin.x;
|
2017-03-08 09:35:51 +00:00
|
|
|
|
|
|
|
// If axes are drawn, skip the lines that would cover them
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_axesEnabled && x == 0.0 )
|
2017-03-08 09:35:51 +00:00
|
|
|
continue;
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
SetLineWidth( ( i % m_gridTick == 0 ) ? majorLineWidth : minorLineWidth );
|
|
|
|
VECTOR2D a( x, gridStartY * gridScreenSize.y + m_gridOrigin.y );
|
|
|
|
VECTOR2D b( x, gridEndY * gridScreenSize.y + m_gridOrigin.y );
|
2019-02-21 13:40:09 +00:00
|
|
|
DrawLine( a, b );
|
2017-03-01 09:29:19 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_nonCachedManager->EndDrawing();
|
2018-10-12 17:08:25 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_gridStyle == GRID_STYLE::DOTS )
|
2017-03-01 09:29:19 +00:00
|
|
|
glDisable( GL_STENCIL_TEST );
|
|
|
|
}
|
2016-05-02 14:15:24 +00:00
|
|
|
|
|
|
|
glEnable( GL_DEPTH_TEST );
|
|
|
|
glEnable( GL_TEXTURE_2D );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
void OPENGL_GAL::ResizeScreen( int aWidth, int aHeight )
|
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-03-19 21:38:53 +00:00
|
|
|
m_screenSize = VECTOR2I( aWidth, aHeight );
|
2015-07-01 01:46:42 +00:00
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
// Resize framebuffers
|
2020-06-03 22:22:37 +00:00
|
|
|
const float scaleFactor = GetScaleFactor();
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->Resize( aWidth * scaleFactor, aHeight * scaleFactor );
|
|
|
|
m_isFramebufferInitialized = false;
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
wxGLCanvas::SetSize( aWidth, aHeight );
|
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-07-30 16:29:54 +00:00
|
|
|
bool OPENGL_GAL::Show( bool aShow )
|
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-07-30 16:29:54 +00:00
|
|
|
bool s = wxGLCanvas::Show( aShow );
|
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-07-30 16:29:54 +00:00
|
|
|
if( aShow )
|
|
|
|
wxGLCanvas::Raise();
|
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-07-30 16:29:54 +00:00
|
|
|
return s;
|
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-07-30 16:29:54 +00:00
|
|
|
void OPENGL_GAL::Flush()
|
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-07-30 16:29:54 +00:00
|
|
|
glFlush();
|
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-02-16 22:25:27 +00:00
|
|
|
void OPENGL_GAL::ClearScreen()
|
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
|
|
|
{
|
2017-03-04 07:51:35 +00:00
|
|
|
// Clear screen
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
2021-02-16 22:25:27 +00:00
|
|
|
|
2018-01-06 14:47:17 +00:00
|
|
|
// NOTE: Black used here instead of m_clearColor; it will be composited later
|
|
|
|
glClearColor( 0, 0, 0, 1 );
|
2016-05-02 14:15:24 +00:00
|
|
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
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-02-13 18:31:27 +00:00
|
|
|
void OPENGL_GAL::Transform( const MATRIX3x3D& aTransformation )
|
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
|
|
|
{
|
|
|
|
GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
matrixData[0] = aTransformation.m_data[0][0];
|
|
|
|
matrixData[1] = aTransformation.m_data[1][0];
|
|
|
|
matrixData[2] = aTransformation.m_data[2][0];
|
|
|
|
matrixData[4] = aTransformation.m_data[0][1];
|
|
|
|
matrixData[5] = aTransformation.m_data[1][1];
|
|
|
|
matrixData[6] = aTransformation.m_data[2][1];
|
|
|
|
matrixData[12] = aTransformation.m_data[0][2];
|
|
|
|
matrixData[13] = aTransformation.m_data[1][2];
|
|
|
|
matrixData[14] = aTransformation.m_data[2][2];
|
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
|
|
|
|
|
|
|
glMultMatrixd( matrixData );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::Rotate( double aAngle )
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f );
|
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-04-17 10:48:37 +00:00
|
|
|
void OPENGL_GAL::Translate( const VECTOR2D& aVector )
|
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-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Translate( aVector.x, aVector.y, 0.0f );
|
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-04-17 10:48:37 +00:00
|
|
|
void OPENGL_GAL::Scale( const VECTOR2D& aScale )
|
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-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Scale( aScale.x, aScale.y, 0.0f );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::Save()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->PushMatrix();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::Restore()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->PopMatrix();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int OPENGL_GAL::BeginGroup()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_isGrouping = true;
|
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-03-19 21:38:53 +00:00
|
|
|
std::shared_ptr<VERTEX_ITEM> newItem = std::make_shared<VERTEX_ITEM>( *m_cachedManager );
|
2021-02-16 22:25:27 +00:00
|
|
|
int groupNumber = getNewGroupNumber();
|
2021-03-19 21:38:53 +00:00
|
|
|
m_groups.insert( std::make_pair( groupNumber, newItem ) );
|
2013-04-30 13:59:32 +00:00
|
|
|
|
2013-06-27 09:54:49 +00:00
|
|
|
return groupNumber;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::EndGroup()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->FinishItem();
|
|
|
|
m_isGrouping = false;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::DrawGroup( int aGroupNumber )
|
|
|
|
{
|
2021-04-08 22:10:09 +00:00
|
|
|
auto group = m_groups.find( aGroupNumber );
|
|
|
|
|
|
|
|
if( group != m_groups.end() )
|
|
|
|
m_cachedManager->DrawItem( *group->second );
|
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-25 15:12:54 +00:00
|
|
|
void OPENGL_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
|
|
|
|
{
|
2021-04-08 22:10:09 +00:00
|
|
|
auto group = m_groups.find( aGroupNumber );
|
|
|
|
|
|
|
|
if( group != m_groups.end() )
|
|
|
|
m_cachedManager->ChangeItemColor( *group->second, aNewColor );
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-26 14:31:52 +00:00
|
|
|
void OPENGL_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth )
|
|
|
|
{
|
2021-04-08 22:10:09 +00:00
|
|
|
auto group = m_groups.find( aGroupNumber );
|
|
|
|
|
|
|
|
if( group != m_groups.end() )
|
|
|
|
m_cachedManager->ChangeItemDepth( *group->second, aDepth );
|
2013-06-26 14:31:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
void OPENGL_GAL::DeleteGroup( int aGroupNumber )
|
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-09-12 07:44:57 +00:00
|
|
|
// Frees memory in the container as well
|
2021-03-19 21:38:53 +00:00
|
|
|
m_groups.erase( aGroupNumber );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
2013-06-27 14:05:15 +00:00
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
void OPENGL_GAL::ClearCache()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_bitmapCache = std::make_unique<GL_BITMAP_CACHE>();
|
2018-07-30 14:18:53 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_groups.clear();
|
2017-08-08 12:25:03 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isInitialized )
|
|
|
|
m_cachedManager->Clear();
|
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-10-14 18:40:36 +00:00
|
|
|
void OPENGL_GAL::SetTarget( RENDER_TARGET aTarget )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
|
|
|
switch( aTarget )
|
|
|
|
{
|
|
|
|
default:
|
2021-03-19 21:38:53 +00:00
|
|
|
case TARGET_CACHED: m_currentManager = m_cachedManager; break;
|
|
|
|
case TARGET_NONCACHED: m_currentManager = m_nonCachedManager; break;
|
|
|
|
case TARGET_OVERLAY: m_currentManager = m_overlayManager; break;
|
2022-01-02 15:00:07 +00:00
|
|
|
case TARGET_TEMP: m_currentManager = m_tempManager; break;
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
2013-08-06 12:57:48 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentTarget = aTarget;
|
2013-08-06 12:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-14 18:40:36 +00:00
|
|
|
RENDER_TARGET OPENGL_GAL::GetTarget() const
|
2013-08-06 12:57:48 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
return m_currentTarget;
|
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-10-14 18:40:36 +00:00
|
|
|
void OPENGL_GAL::ClearTarget( RENDER_TARGET aTarget )
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
|
|
|
// Save the current state
|
2021-03-19 21:38:53 +00:00
|
|
|
unsigned int oldTarget = m_compositor->GetBuffer();
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
switch( aTarget )
|
|
|
|
{
|
|
|
|
// Cached and noncached items are rendered to the same buffer
|
|
|
|
default:
|
|
|
|
case TARGET_CACHED:
|
|
|
|
case TARGET_NONCACHED:
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( m_mainBuffer );
|
2013-08-19 09:02:38 +00:00
|
|
|
break;
|
|
|
|
|
2022-01-02 15:00:07 +00:00
|
|
|
case TARGET_TEMP:
|
|
|
|
m_compositor->SetBuffer( m_tempBuffer );
|
|
|
|
break;
|
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
case TARGET_OVERLAY:
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_overlayBuffer )
|
|
|
|
m_compositor->SetBuffer( m_overlayBuffer );
|
2013-08-19 09:02:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
if( aTarget != TARGET_OVERLAY )
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->ClearBuffer( m_clearColor );
|
|
|
|
else if( m_overlayBuffer )
|
|
|
|
m_compositor->ClearBuffer( COLOR4D::BLACK );
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
// Restore the previous state
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( oldTarget );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-21 16:14:37 +00:00
|
|
|
bool OPENGL_GAL::HasTarget( RENDER_TARGET aTarget )
|
|
|
|
{
|
|
|
|
switch( aTarget )
|
|
|
|
{
|
|
|
|
default:
|
2022-01-02 15:00:07 +00:00
|
|
|
case TARGET_TEMP:
|
2020-06-21 16:14:37 +00:00
|
|
|
case TARGET_CACHED:
|
2021-02-16 22:25:27 +00:00
|
|
|
case TARGET_NONCACHED: return true;
|
2021-03-19 21:38:53 +00:00
|
|
|
case TARGET_OVERLAY: return ( m_overlayBuffer != 0 );
|
2020-06-21 16:14:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-24 16:00:46 +00:00
|
|
|
void OPENGL_GAL::StartDiffLayer()
|
|
|
|
{
|
|
|
|
m_currentManager->EndDrawing();
|
2022-01-02 15:00:07 +00:00
|
|
|
SetTarget( TARGET_TEMP );
|
|
|
|
ClearTarget( TARGET_TEMP );
|
2021-08-24 16:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::EndDiffLayer()
|
|
|
|
{
|
2022-01-02 15:00:07 +00:00
|
|
|
glBlendEquation( GL_MAX );
|
2021-08-24 16:00:46 +00:00
|
|
|
m_currentManager->EndDrawing();
|
2022-01-02 15:00:07 +00:00
|
|
|
glBlendEquation( GL_FUNC_ADD );
|
|
|
|
|
|
|
|
m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer );
|
2021-08-24 16:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-05 01:35:01 +00:00
|
|
|
bool OPENGL_GAL::SetNativeCursorStyle( KICURSOR aCursor )
|
|
|
|
{
|
|
|
|
// Store the current cursor type and get the wxCursor for it
|
|
|
|
if( !GAL::SetNativeCursorStyle( aCursor ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
m_currentwxCursor = CURSOR_STORE::GetCursor( m_currentNativeCursor );
|
|
|
|
|
|
|
|
// Update the cursor in the wx control
|
|
|
|
HIDPI_GL_CANVAS::SetCursor( m_currentwxCursor );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::onSetNativeCursor( wxSetCursorEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.SetCursor( m_currentwxCursor );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-27 16:08:32 +00:00
|
|
|
void OPENGL_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2013-08-28 15:06:07 +00:00
|
|
|
// Now we should only store the position of the mouse cursor
|
|
|
|
// The real drawing routines are in blitCursor()
|
2021-03-19 21:38:53 +00:00
|
|
|
//VECTOR2D screenCursor = m_worldScreenMatrix * aCursorPosition;
|
|
|
|
//m_cursorPosition = m_screenWorldMatrix * VECTOR2D( screenCursor.x, screenCursor.y );
|
|
|
|
m_cursorPosition = aCursorPosition;
|
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-02-25 13:28:09 +00:00
|
|
|
void OPENGL_GAL::drawLineQuad( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint )
|
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-02-25 13:28:09 +00:00
|
|
|
/* Helper drawing: ____--- v3 ^
|
|
|
|
* ____---- ... \ \
|
|
|
|
* ____---- ... \ end \
|
|
|
|
* v1 ____---- ... ____---- \ width
|
|
|
|
* ---- ...___---- \ \
|
|
|
|
* \ ___...-- \ v
|
|
|
|
* \ ____----... ____---- v2
|
|
|
|
* ---- ... ____----
|
|
|
|
* start \ ... ____----
|
|
|
|
* \... ____----
|
|
|
|
* ----
|
|
|
|
* v0
|
|
|
|
* dots mark triangles' hypotenuses
|
|
|
|
*/
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
auto v1 = m_currentManager->GetTransformation()
|
2021-02-16 22:25:27 +00:00
|
|
|
* glm::vec4( aStartPoint.x, aStartPoint.y, 0.0, 0.0 );
|
2021-03-19 21:38:53 +00:00
|
|
|
auto v2 = m_currentManager->GetTransformation()
|
|
|
|
* glm::vec4( aEndPoint.x, aEndPoint.y, 0.0, 0.0 );
|
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
|
|
|
|
2019-01-21 18:42:06 +00:00
|
|
|
VECTOR2D vs( v2.x - v1.x, v2.y - v1.y );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 6 );
|
2016-05-02 13:56:10 +00:00
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
// Line width is maintained by the vertex shader
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_LINE_A, m_lineWidth, vs.x, vs.y );
|
|
|
|
m_currentManager->Vertex( aStartPoint, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_LINE_B, m_lineWidth, vs.x, vs.y );
|
|
|
|
m_currentManager->Vertex( aStartPoint, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_LINE_C, m_lineWidth, vs.x, vs.y );
|
|
|
|
m_currentManager->Vertex( aEndPoint, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_LINE_D, m_lineWidth, vs.x, vs.y );
|
|
|
|
m_currentManager->Vertex( aEndPoint, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_LINE_E, m_lineWidth, vs.x, vs.y );
|
|
|
|
m_currentManager->Vertex( aEndPoint, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_LINE_F, m_lineWidth, vs.x, vs.y );
|
|
|
|
m_currentManager->Vertex( aStartPoint, m_layerDepth );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::drawSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle )
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2013-07-30 16:29:54 +00:00
|
|
|
drawFilledSemiCircle( aCenterPoint, aRadius, aAngle );
|
|
|
|
}
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2021-03-22 19:34:33 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
|
|
|
|
m_strokeColor.a );
|
2013-07-30 16:29:54 +00:00
|
|
|
drawStrokedSemiCircle( aCenterPoint, aRadius, aAngle );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
void OPENGL_GAL::drawFilledSemiCircle( const VECTOR2D& aCenterPoint, double aRadius, double aAngle )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
|
|
|
Save();
|
2016-05-02 13:56:10 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 3 );
|
|
|
|
m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f );
|
|
|
|
m_currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
/* Draw a triangle that contains the semicircle, then shade it to leave only
|
2016-05-02 13:56:10 +00:00
|
|
|
* the semicircle. Parameters given to Shader() are indices of the triangle's vertices
|
2014-02-25 13:28:09 +00:00
|
|
|
* (if you want to understand more, check the vertex shader source [shader.vert]).
|
|
|
|
* Shader uses these coordinates to determine if fragments are inside the semicircle or not.
|
2013-07-30 16:29:54 +00:00
|
|
|
* v2
|
|
|
|
* /\
|
|
|
|
* /__\
|
|
|
|
* v0 //__\\ v1
|
|
|
|
*/
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FILLED_CIRCLE, 4.0f );
|
|
|
|
m_currentManager->Vertex( -aRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v0
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FILLED_CIRCLE, 5.0f );
|
|
|
|
m_currentManager->Vertex( aRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v1
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FILLED_CIRCLE, 6.0f );
|
|
|
|
m_currentManager->Vertex( 0.0f, aRadius * 2.0f, m_layerDepth ); // v2
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRadius,
|
|
|
|
double aAngle )
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
double outerRadius = aRadius + ( m_lineWidth / 2 );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
Save();
|
2016-05-02 13:56:10 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 3 );
|
|
|
|
m_currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0f );
|
|
|
|
m_currentManager->Rotate( aAngle, 0.0f, 0.0f, 1.0f );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
/* Draw a triangle that contains the semicircle, then shade it to leave only
|
2016-05-02 13:56:10 +00:00
|
|
|
* the semicircle. Parameters given to Shader() are indices of the triangle's vertices
|
2014-02-25 13:28:09 +00:00
|
|
|
* (if you want to understand more, check the vertex shader source [shader.vert]), the
|
|
|
|
* radius and the line width. Shader uses these coordinates to determine if fragments are
|
|
|
|
* inside the semicircle or not.
|
2013-07-30 16:29:54 +00:00
|
|
|
* v2
|
|
|
|
* /\
|
|
|
|
* /__\
|
|
|
|
* v0 //__\\ v1
|
|
|
|
*/
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 4.0f, aRadius, m_lineWidth );
|
|
|
|
m_currentManager->Vertex( -outerRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v0
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 5.0f, aRadius, m_lineWidth );
|
|
|
|
m_currentManager->Vertex( outerRadius * 3.0f / sqrt( 3.0f ), 0.0f, m_layerDepth ); // v1
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_STROKED_CIRCLE, 6.0f, aRadius, m_lineWidth );
|
|
|
|
m_currentManager->Vertex( 0.0f, outerRadius * 2.0f, m_layerDepth ); // v2
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
Restore();
|
|
|
|
}
|
|
|
|
|
2017-12-01 15:53:58 +00:00
|
|
|
|
2017-01-24 13:31:57 +00:00
|
|
|
void OPENGL_GAL::drawPolygon( GLdouble* aPoints, int aPointCount )
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isFillEnabled )
|
2017-12-08 11:44:46 +00:00
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_NONE );
|
|
|
|
m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a );
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2017-12-08 11:44:46 +00:00
|
|
|
// Any non convex polygon needs to be tesselated
|
|
|
|
// for this purpose the GLU standard functions are used
|
2021-03-19 21:38:53 +00:00
|
|
|
TessParams params = { m_currentManager, m_tessIntersects };
|
|
|
|
gluTessBeginPolygon( m_tesselator, ¶ms );
|
|
|
|
gluTessBeginContour( m_tesselator );
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2017-12-08 11:44:46 +00:00
|
|
|
GLdouble* point = aPoints;
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2017-12-08 11:44:46 +00:00
|
|
|
for( int i = 0; i < aPointCount; ++i )
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
gluTessVertex( m_tesselator, point, point );
|
2021-02-16 22:25:27 +00:00
|
|
|
point += 3; // 3 coordinates
|
2017-12-08 11:44:46 +00:00
|
|
|
}
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
gluTessEndContour( m_tesselator );
|
|
|
|
gluTessEndPolygon( m_tesselator );
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2017-12-08 11:44:46 +00:00
|
|
|
// Free allocated intersecting points
|
2021-03-19 21:38:53 +00:00
|
|
|
m_tessIntersects.clear();
|
2017-12-08 11:44:46 +00:00
|
|
|
}
|
2017-07-28 08:34:45 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_isStrokeEnabled )
|
2017-12-08 11:44:46 +00:00
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
drawPolyline(
|
|
|
|
[&]( int idx )
|
|
|
|
{
|
|
|
|
return VECTOR2D( aPoints[idx * 3], aPoints[idx * 3 + 1] );
|
|
|
|
},
|
2017-07-28 08:34:45 +00:00
|
|
|
aPointCount );
|
2017-12-08 11:44:46 +00:00
|
|
|
}
|
2017-01-24 13:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
void OPENGL_GAL::drawPolyline( const std::function<VECTOR2D( int )>& aPointGetter, int aPointCount )
|
2017-01-24 13:31:57 +00:00
|
|
|
{
|
2020-08-21 22:17:15 +00:00
|
|
|
wxCHECK( aPointCount >= 2, /* return */ );
|
2017-01-24 13:31:57 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a );
|
2017-01-24 13:31:57 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 1; i < aPointCount; ++i )
|
|
|
|
{
|
|
|
|
auto start = aPointGetter( i - 1 );
|
|
|
|
auto end = aPointGetter( i );
|
|
|
|
|
|
|
|
drawLineQuad( start, end );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-02 14:12:18 +00:00
|
|
|
int OPENGL_GAL::drawBitmapChar( unsigned long aChar )
|
2016-05-02 14:12:18 +00:00
|
|
|
{
|
2016-10-20 12:29:51 +00:00
|
|
|
const float TEX_X = font_image.width;
|
|
|
|
const float TEX_Y = font_image.height;
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2017-12-07 16:58:21 +00:00
|
|
|
// handle space
|
|
|
|
if( aChar == ' ' )
|
|
|
|
{
|
|
|
|
const FONT_GLYPH_TYPE* g = LookupGlyph( 'x' );
|
2018-01-06 05:02:28 +00:00
|
|
|
wxASSERT( g );
|
2020-02-02 07:55:24 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
if( !g ) // Should not happen.
|
2020-02-02 07:55:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-12-07 16:58:21 +00:00
|
|
|
Translate( VECTOR2D( g->advance, 0 ) );
|
|
|
|
return g->advance;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FONT_GLYPH_TYPE* glyph = LookupGlyph( aChar );
|
2017-09-19 16:56:33 +00:00
|
|
|
|
2021-04-05 13:24:57 +00:00
|
|
|
// If the glyph is not found (happens for many esoteric unicode chars)
|
2018-10-20 16:08:36 +00:00
|
|
|
// shows a '?' instead.
|
2017-12-07 16:58:21 +00:00
|
|
|
if( !glyph )
|
2018-10-20 16:08:36 +00:00
|
|
|
glyph = LookupGlyph( '?' );
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
if( !glyph ) // Should not happen.
|
2017-12-07 16:58:21 +00:00
|
|
|
return 0;
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2016-10-20 12:29:51 +00:00
|
|
|
const float X = glyph->atlas_x + font_information.smooth_pixels;
|
|
|
|
const float Y = glyph->atlas_y + font_information.smooth_pixels;
|
2021-02-16 22:25:27 +00:00
|
|
|
const float XOFF = glyph->minx;
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2016-10-20 12:29:51 +00:00
|
|
|
// adjust for height rounding
|
2021-02-16 22:25:27 +00:00
|
|
|
const float round_adjust = ( glyph->maxy - glyph->miny )
|
2016-10-20 12:29:51 +00:00
|
|
|
- float( glyph->atlas_h - font_information.smooth_pixels * 2 );
|
2021-02-16 22:25:27 +00:00
|
|
|
const float top_adjust = font_information.max_y - glyph->maxy;
|
2016-10-20 12:29:51 +00:00
|
|
|
const float YOFF = round_adjust + top_adjust;
|
2021-02-16 22:25:27 +00:00
|
|
|
const float W = glyph->atlas_w - font_information.smooth_pixels * 2;
|
|
|
|
const float H = glyph->atlas_h - font_information.smooth_pixels * 2;
|
|
|
|
const float B = 0;
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 6 );
|
2016-10-20 12:29:51 +00:00
|
|
|
Translate( VECTOR2D( XOFF, YOFF ) );
|
2021-02-16 22:25:27 +00:00
|
|
|
|
2016-10-20 12:29:51 +00:00
|
|
|
/* Glyph:
|
2021-02-16 22:25:27 +00:00
|
|
|
* v0 v1
|
|
|
|
* +--+
|
|
|
|
* | /|
|
|
|
|
* |/ |
|
|
|
|
* +--+
|
|
|
|
* v2 v3
|
|
|
|
*/
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FONT, X / TEX_X, ( Y + H ) / TEX_Y );
|
|
|
|
m_currentManager->Vertex( -B, -B, 0 ); // v0
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, ( Y + H ) / TEX_Y );
|
|
|
|
m_currentManager->Vertex( W + B, -B, 0 ); // v1
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FONT, X / TEX_X, Y / TEX_Y );
|
|
|
|
m_currentManager->Vertex( -B, H + B, 0 ); // v2
|
2016-05-02 14:12:18 +00:00
|
|
|
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, ( Y + H ) / TEX_Y );
|
|
|
|
m_currentManager->Vertex( W + B, -B, 0 ); // v1
|
2016-09-14 08:00:49 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FONT, X / TEX_X, Y / TEX_Y );
|
|
|
|
m_currentManager->Vertex( -B, H + B, 0 ); // v2
|
2016-09-14 08:00:49 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( SHADER_FONT, ( X + W ) / TEX_X, Y / TEX_Y );
|
|
|
|
m_currentManager->Vertex( W + B, H + B, 0 ); // v3
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2016-10-20 12:29:51 +00:00
|
|
|
Translate( VECTOR2D( -XOFF + glyph->advance, -YOFF ) );
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2016-10-20 12:29:51 +00:00
|
|
|
return glyph->advance;
|
2016-05-02 14:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::drawBitmapOverbar( double aLength, double aHeight )
|
|
|
|
{
|
2016-09-14 08:00:49 +00:00
|
|
|
// To draw an overbar, simply draw an overbar
|
2016-12-22 14:26:31 +00:00
|
|
|
const FONT_GLYPH_TYPE* glyph = LookupGlyph( '_' );
|
2017-12-07 16:58:21 +00:00
|
|
|
wxCHECK( glyph, /* void */ );
|
2017-11-01 09:20:13 +00:00
|
|
|
|
2016-10-20 12:29:51 +00:00
|
|
|
const float H = glyph->maxy - glyph->miny;
|
2016-05-02 14:12:18 +00:00
|
|
|
|
|
|
|
Save();
|
2016-09-14 08:00:49 +00:00
|
|
|
|
2021-07-25 11:37:23 +00:00
|
|
|
Translate( VECTOR2D( -aLength, -aHeight ) );
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Reserve( 6 );
|
|
|
|
m_currentManager->Color( m_strokeColor.r, m_strokeColor.g, m_strokeColor.b, m_strokeColor.a );
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Shader( 0 );
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Vertex( 0, 0, 0 ); // v0
|
|
|
|
m_currentManager->Vertex( aLength, 0, 0 ); // v1
|
|
|
|
m_currentManager->Vertex( 0, H, 0 ); // v2
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_currentManager->Vertex( aLength, 0, 0 ); // v1
|
|
|
|
m_currentManager->Vertex( 0, H, 0 ); // v2
|
|
|
|
m_currentManager->Vertex( aLength, H, 0 ); // v3
|
2016-05-02 14:12:18 +00:00
|
|
|
|
|
|
|
Restore();
|
2016-05-02 14:12:18 +00:00
|
|
|
}
|
|
|
|
|
2017-12-07 16:20:20 +00:00
|
|
|
|
|
|
|
std::pair<VECTOR2D, float> OPENGL_GAL::computeBitmapTextSize( const UTF8& aText ) const
|
2016-05-02 14:12:18 +00:00
|
|
|
{
|
2021-02-07 13:10:30 +00:00
|
|
|
static const FONT_GLYPH_TYPE* defaultGlyph = LookupGlyph( '(' ); // for strange chars
|
|
|
|
|
2016-05-02 14:12:18 +00:00
|
|
|
VECTOR2D textSize( 0, 0 );
|
2021-02-07 13:10:30 +00:00
|
|
|
float commonOffset = std::numeric_limits<float>::max();
|
2021-06-05 13:52:58 +00:00
|
|
|
float charHeight = font_information.max_y - defaultGlyph->miny;
|
|
|
|
int overbarDepth = -1;
|
|
|
|
int braceNesting = 0;
|
2016-05-02 14:12:18 +00:00
|
|
|
|
2017-12-07 16:20:20 +00:00
|
|
|
for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
|
2016-05-02 14:12:18 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
if( *chIt == '~' && overbarDepth == -1 )
|
2021-02-07 13:10:30 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
UTF8::uni_iter lookahead = chIt;
|
2021-02-07 13:10:30 +00:00
|
|
|
|
2021-06-05 13:52:58 +00:00
|
|
|
if( ++lookahead != end && *lookahead == '{' )
|
2021-02-07 13:10:30 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
chIt = lookahead;
|
|
|
|
overbarDepth = braceNesting;
|
|
|
|
braceNesting++;
|
|
|
|
continue;
|
2021-02-07 13:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-05 13:52:58 +00:00
|
|
|
else if( *chIt == '{' )
|
2021-02-07 13:10:30 +00:00
|
|
|
{
|
2021-06-05 13:52:58 +00:00
|
|
|
braceNesting++;
|
|
|
|
}
|
|
|
|
else if( *chIt == '}' )
|
|
|
|
{
|
|
|
|
if( braceNesting > 0 )
|
|
|
|
braceNesting--;
|
|
|
|
|
|
|
|
if( braceNesting == overbarDepth )
|
|
|
|
{
|
|
|
|
overbarDepth = -1;
|
|
|
|
continue;
|
|
|
|
}
|
2021-02-07 13:10:30 +00:00
|
|
|
}
|
2017-09-19 16:56:33 +00:00
|
|
|
|
2021-02-07 13:10:30 +00:00
|
|
|
const FONT_GLYPH_TYPE* glyph = LookupGlyph( *chIt );
|
2017-09-19 16:56:33 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
if( !glyph // Not coded in font
|
|
|
|
|| *chIt == '-' || *chIt == '_' ) // Strange size of these 2 chars
|
2017-09-19 16:56:33 +00:00
|
|
|
{
|
2018-01-07 15:00:29 +00:00
|
|
|
glyph = defaultGlyph;
|
2017-09-19 16:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( glyph )
|
2021-02-07 13:10:30 +00:00
|
|
|
textSize.x += glyph->advance;
|
2016-05-02 14:12:18 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 13:52:58 +00:00
|
|
|
textSize.y = std::max<float>( textSize.y, charHeight );
|
2018-01-07 15:00:29 +00:00
|
|
|
commonOffset = std::min<float>( font_information.max_y - defaultGlyph->maxy, commonOffset );
|
2016-05-03 09:58:48 +00:00
|
|
|
textSize.y -= commonOffset;
|
|
|
|
|
|
|
|
return std::make_pair( textSize, commonOffset );
|
2016-05-02 14:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-15 12:00:58 +00:00
|
|
|
void OPENGL_GAL::onPaint( wxPaintEvent& aEvent )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2020-07-15 12:00:58 +00:00
|
|
|
PostPaint( aEvent );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::skipMouseEvent( wxMouseEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Post the mouse event to the event listener registered in constructor, if any
|
2021-03-19 21:38:53 +00:00
|
|
|
if( m_mouseListener )
|
|
|
|
wxPostEvent( m_mouseListener, aEvent );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-28 15:06:07 +00:00
|
|
|
void OPENGL_GAL::blitCursor()
|
|
|
|
{
|
2017-03-18 22:00:21 +00:00
|
|
|
if( !IsCursorEnabled() )
|
2013-08-28 15:06:07 +00:00
|
|
|
return;
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
|
2013-08-28 15:06:07 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
const int cursorSize = m_fullscreenCursor ? 8000 : 80;
|
2017-03-19 20:51:59 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
VECTOR2D cursorBegin = m_cursorPosition - cursorSize / ( 2 * m_worldScale );
|
|
|
|
VECTOR2D cursorEnd = m_cursorPosition + cursorSize / ( 2 * m_worldScale );
|
2014-02-13 19:23:28 +00:00
|
|
|
VECTOR2D cursorCenter = ( cursorBegin + cursorEnd ) / 2;
|
2013-08-28 15:06:07 +00:00
|
|
|
|
2017-03-18 22:00:21 +00:00
|
|
|
const COLOR4D cColor = getCursorColor();
|
2021-02-16 22:25:27 +00:00
|
|
|
const COLOR4D color( cColor.r * cColor.a, cColor.g * cColor.a, cColor.b * cColor.a, 1.0 );
|
2017-03-18 22:00:21 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
2013-08-28 15:06:07 +00:00
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
glLineWidth( 1.0 );
|
2017-03-18 22:00:21 +00:00
|
|
|
glColor4d( color.r, color.g, color.b, color.a );
|
2013-08-28 15:06:07 +00:00
|
|
|
|
|
|
|
glBegin( GL_LINES );
|
|
|
|
glVertex2d( cursorCenter.x, cursorBegin.y );
|
|
|
|
glVertex2d( cursorCenter.x, cursorEnd.y );
|
|
|
|
|
|
|
|
glVertex2d( cursorBegin.x, cursorCenter.y );
|
|
|
|
glVertex2d( cursorEnd.x, cursorCenter.y );
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
unsigned int OPENGL_GAL::getNewGroupNumber()
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
wxASSERT_MSG( m_groups.size() < std::numeric_limits<unsigned int>::max(),
|
2013-07-30 16:29:54 +00:00
|
|
|
wxT( "There are no free slots to store a group" ) );
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
while( m_groups.find( m_groupCounter ) != m_groups.end() )
|
|
|
|
m_groupCounter++;
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
return m_groupCounter++;
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-13 15:48:23 +00:00
|
|
|
void OPENGL_GAL::init()
|
2015-04-20 12:16:41 +00:00
|
|
|
{
|
2017-01-13 15:48:23 +00:00
|
|
|
wxASSERT( IsShownOnScreen() );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2021-01-09 20:13:46 +00:00
|
|
|
wxASSERT_MSG( m_isContextLocked, "This should only be called from within a locked context." );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2020-07-03 19:57:00 +00:00
|
|
|
// IsDisplayAttr() handles WX_GL_{MAJOR,MINOR}_VERSION correctly only in 3.0.4
|
|
|
|
// starting with 3.1.0 one should use wxGLContext::IsOk() (done by GL_CONTEXT_MANAGER)
|
|
|
|
#if wxCHECK_VERSION( 3, 0, 3 ) and !wxCHECK_VERSION( 3, 1, 0 )
|
|
|
|
const int attr[] = { WX_GL_MAJOR_VERSION, 2, WX_GL_MINOR_VERSION, 1, 0 };
|
|
|
|
|
|
|
|
if( !IsDisplaySupported( attr ) )
|
|
|
|
throw std::runtime_error( "OpenGL 2.1 or higher is required!" );
|
|
|
|
#endif /* wxCHECK_VERSION( 3, 0, 3 ) */
|
|
|
|
|
|
|
|
// Check correct initialization from the constructor
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_glMainContext )
|
2020-07-03 19:57:00 +00:00
|
|
|
throw std::runtime_error( "Could not create the main OpenGL context" );
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_glPrivContext )
|
2020-07-03 19:57:00 +00:00
|
|
|
throw std::runtime_error( "Could not create a private OpenGL context" );
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
if( m_tesselator == nullptr )
|
2021-03-19 21:38:53 +00:00
|
|
|
throw std::runtime_error( "Could not create the m_tesselator" );
|
2021-04-05 13:24:57 +00:00
|
|
|
// End initialization checks
|
2020-07-03 19:57:00 +00:00
|
|
|
|
2017-01-13 15:48:23 +00:00
|
|
|
GLenum err = glewInit();
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
if( GLEW_OK != err )
|
|
|
|
throw std::runtime_error( (const char*) glewGetErrorString( err ) );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
// Check the OpenGL version (minimum 2.1 is required)
|
|
|
|
if( !GLEW_VERSION_2_1 )
|
|
|
|
throw std::runtime_error( "OpenGL 2.1 or higher is required!" );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
#if defined( __LINUX__ ) // calling enableGlDebug crashes opengl on some OS (OSX and some Windows)
|
2018-02-14 07:51:48 +00:00
|
|
|
#ifdef DEBUG
|
2018-10-12 22:42:44 +00:00
|
|
|
if( GLEW_ARB_debug_output )
|
|
|
|
enableGlDebug( true );
|
2018-02-14 07:51:48 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
// Framebuffers have to be supported
|
|
|
|
if( !GLEW_EXT_framebuffer_object )
|
|
|
|
throw std::runtime_error( "Framebuffer objects are not supported!" );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
// Vertex buffer has to be supported
|
|
|
|
if( !GLEW_ARB_vertex_buffer_object )
|
|
|
|
throw std::runtime_error( "Vertex buffer objects are not supported!" );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
// Prepare shaders
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_shader->IsLinked()
|
|
|
|
&& !m_shader->LoadShaderFromStrings( SHADER_TYPE_VERTEX,
|
|
|
|
BUILTIN_SHADERS::kicad_vertex_shader ) )
|
|
|
|
{
|
2018-10-12 22:42:44 +00:00
|
|
|
throw std::runtime_error( "Cannot compile vertex shader!" );
|
2021-03-19 21:38:53 +00:00
|
|
|
}
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_shader->IsLinked()
|
|
|
|
&& !m_shader->LoadShaderFromStrings( SHADER_TYPE_FRAGMENT,
|
|
|
|
BUILTIN_SHADERS::kicad_fragment_shader ) )
|
|
|
|
{
|
2018-10-12 22:42:44 +00:00
|
|
|
throw std::runtime_error( "Cannot compile fragment shader!" );
|
2021-03-19 21:38:53 +00:00
|
|
|
}
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
if( !m_shader->IsLinked() && !m_shader->Link() )
|
2018-10-12 22:42:44 +00:00
|
|
|
throw std::runtime_error( "Cannot link the shaders!" );
|
2015-04-20 12:16:41 +00:00
|
|
|
|
2018-10-12 22:42:44 +00:00
|
|
|
// Check if video card supports textures big enough to fit the font atlas
|
|
|
|
int maxTextureSize;
|
|
|
|
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTextureSize );
|
2016-05-02 14:04:45 +00:00
|
|
|
|
2020-07-03 19:57:00 +00:00
|
|
|
if( maxTextureSize < (int) font_image.width || maxTextureSize < (int) font_image.height )
|
2017-01-13 15:48:23 +00:00
|
|
|
{
|
2018-10-12 22:42:44 +00:00
|
|
|
// TODO implement software texture scaling
|
|
|
|
// for bitmap fonts and use a higher resolution texture?
|
|
|
|
throw std::runtime_error( "Requested texture size is not supported" );
|
2017-01-13 15:48:23 +00:00
|
|
|
}
|
2015-08-21 08:33:36 +00:00
|
|
|
|
2020-06-26 17:39:43 +00:00
|
|
|
GL_UTILS::SetSwapInterval( -1 );
|
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager = new VERTEX_MANAGER( true );
|
|
|
|
m_nonCachedManager = new VERTEX_MANAGER( false );
|
|
|
|
m_overlayManager = new VERTEX_MANAGER( false );
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempManager = new VERTEX_MANAGER( false );
|
2017-08-08 12:25:03 +00:00
|
|
|
|
2017-01-13 15:48:23 +00:00
|
|
|
// Make VBOs use shaders
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->SetShader( *m_shader );
|
|
|
|
m_nonCachedManager->SetShader( *m_shader );
|
|
|
|
m_overlayManager->SetShader( *m_shader );
|
2022-01-02 15:00:07 +00:00
|
|
|
m_tempManager->SetShader( *m_shader );
|
2015-08-21 08:33:36 +00:00
|
|
|
|
2021-03-19 21:38:53 +00:00
|
|
|
m_isInitialized = true;
|
2015-08-21 08:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
// Callback functions for the tesselator. Compare Redbook Chapter 11.
|
2013-07-30 16:29:54 +00:00
|
|
|
void CALLBACK VertexCallback( GLvoid* aVertexPtr, void* aData )
|
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
GLdouble* vertex = static_cast<GLdouble*>( aVertexPtr );
|
2013-07-30 16:29:54 +00:00
|
|
|
OPENGL_GAL::TessParams* param = static_cast<OPENGL_GAL::TessParams*>( aData );
|
2021-02-16 22:25:27 +00:00
|
|
|
VERTEX_MANAGER* vboManager = param->vboManager;
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2016-08-08 12:17:40 +00:00
|
|
|
assert( vboManager );
|
|
|
|
vboManager->Vertex( vertex[0], vertex[1], vertex[2] );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
void CALLBACK CombineCallback( GLdouble coords[3], GLdouble* vertex_data[4], GLfloat weight[4],
|
|
|
|
GLdouble** dataOut, void* aData )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
GLdouble* vertex = new GLdouble[3];
|
2013-07-30 16:29:54 +00:00
|
|
|
OPENGL_GAL::TessParams* param = static_cast<OPENGL_GAL::TessParams*>( aData );
|
|
|
|
|
|
|
|
// Save the pointer so we can delete it later
|
2022-01-15 03:04:47 +00:00
|
|
|
// Note, we use the default_delete for an array because macOS
|
|
|
|
// decides to bundle an ancient libc++ that mismatches the C++17 support of clang
|
|
|
|
param->intersectPoints.emplace_back( vertex, std::default_delete<GLdouble[]>() );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2021-02-16 22:25:27 +00:00
|
|
|
memcpy( vertex, coords, 3 * sizeof( GLdouble ) );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
*dataOut = vertex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-02 08:55:40 +00:00
|
|
|
void CALLBACK EdgeCallback( GLboolean aEdgeFlag )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
|
|
|
// This callback is needed to force GLU tesselator to use triangles only
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CALLBACK ErrorCallback( GLenum aErrorCode )
|
|
|
|
{
|
2015-02-15 01:18:35 +00:00
|
|
|
//throw std::runtime_error( std::string( "Tessellation error: " ) +
|
2021-02-16 22:25:27 +00:00
|
|
|
//std::string( (const char*) gluErrorString( aErrorCode ) );
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-20 12:16:41 +00:00
|
|
|
static void InitTesselatorCallbacks( GLUtesselator* aTesselator )
|
2013-07-30 16:29:54 +00:00
|
|
|
{
|
2021-02-16 22:25:27 +00:00
|
|
|
gluTessCallback( aTesselator, GLU_TESS_VERTEX_DATA, (void( CALLBACK* )()) VertexCallback );
|
|
|
|
gluTessCallback( aTesselator, GLU_TESS_COMBINE_DATA, (void( CALLBACK* )()) CombineCallback );
|
|
|
|
gluTessCallback( aTesselator, GLU_TESS_EDGE_FLAG, (void( CALLBACK* )()) EdgeCallback );
|
|
|
|
gluTessCallback( aTesselator, GLU_TESS_ERROR, (void( CALLBACK* )()) ErrorCallback );
|
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
|
|
|
}
|
2018-08-03 09:05:33 +00:00
|
|
|
|
|
|
|
void OPENGL_GAL::EnableDepthTest( bool aEnabled )
|
|
|
|
{
|
2021-03-19 21:38:53 +00:00
|
|
|
m_cachedManager->EnableDepthTest( aEnabled );
|
|
|
|
m_nonCachedManager->EnableDepthTest( aEnabled );
|
|
|
|
m_overlayManager->EnableDepthTest( aEnabled );
|
2018-08-03 09:05:33 +00:00
|
|
|
}
|
2019-01-21 18:42:06 +00:00
|
|
|
|
|
|
|
|
2021-06-02 13:04:23 +00:00
|
|
|
inline double round_to_half_pixel( double f, double r )
|
2019-01-21 18:42:06 +00:00
|
|
|
{
|
2021-06-02 13:04:23 +00:00
|
|
|
return ( ceil( f / r ) - 0.5 ) * r;
|
2019-01-21 18:42:06 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
|
2019-01-21 18:42:06 +00:00
|
|
|
void OPENGL_GAL::ComputeWorldScreenMatrix()
|
|
|
|
{
|
2021-06-02 13:04:23 +00:00
|
|
|
computeWorldScale();
|
2021-03-19 21:38:53 +00:00
|
|
|
auto pixelSize = m_worldScale;
|
2019-01-21 18:42:06 +00:00
|
|
|
|
2021-06-02 13:04:23 +00:00
|
|
|
// we need -m_lookAtPoint == -k * pixelSize + 0.5 * pixelSize for OpenGL
|
|
|
|
// meaning m_lookAtPoint = (k-0.5)*pixelSize with integer k
|
|
|
|
m_lookAtPoint.x = round_to_half_pixel( m_lookAtPoint.x, pixelSize );
|
|
|
|
m_lookAtPoint.y = round_to_half_pixel( m_lookAtPoint.y, pixelSize );
|
2019-01-21 18:42:06 +00:00
|
|
|
|
|
|
|
GAL::ComputeWorldScreenMatrix();
|
|
|
|
}
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
void OPENGL_GAL::DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth, int aTotal )
|
|
|
|
{
|
|
|
|
if( aGlyph.IsStroke() )
|
|
|
|
{
|
2022-01-04 00:44:59 +00:00
|
|
|
const auto& strokeGlyph = static_cast<const KIFONT::STROKE_GLYPH&>( aGlyph );
|
|
|
|
|
|
|
|
for( const std::vector<VECTOR2D>& pointList : strokeGlyph )
|
2021-12-31 14:07:24 +00:00
|
|
|
DrawPolyline( pointList );
|
|
|
|
}
|
|
|
|
else if( aGlyph.IsOutline() )
|
|
|
|
{
|
2022-01-01 01:21:03 +00:00
|
|
|
const auto& outlineGlyph = static_cast<const KIFONT::OUTLINE_GLYPH&>( aGlyph );
|
|
|
|
|
2022-01-07 17:42:43 +00:00
|
|
|
m_currentManager->Shader( SHADER_NONE );
|
|
|
|
m_currentManager->Color( m_fillColor );
|
2022-01-01 01:21:03 +00:00
|
|
|
|
2022-01-07 17:42:43 +00:00
|
|
|
outlineGlyph.Triangulate(
|
2022-01-10 01:53:01 +00:00
|
|
|
[&]( const VECTOR2D& aPt1, const VECTOR2D& aPt2, const VECTOR2D& aPt3 )
|
2022-01-07 17:42:43 +00:00
|
|
|
{
|
2022-01-10 01:53:01 +00:00
|
|
|
m_currentManager->Vertex( aPt1.x, aPt1.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( aPt2.x, aPt2.y, m_layerDepth );
|
|
|
|
m_currentManager->Vertex( aPt3.x, aPt3.y, m_layerDepth );
|
2022-01-07 17:42:43 +00:00
|
|
|
} );
|
|
|
|
}
|
2022-01-01 01:21:03 +00:00
|
|
|
}
|