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.
|
|
|
|
*
|
2019-01-20 09:03:15 +00:00
|
|
|
* Copyright (C) 2013-2019 CERN
|
2024-03-03 15:59:00 +00:00
|
|
|
* Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-06-23 22:58:58 +00:00
|
|
|
*
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <pcb_group.h>
|
|
|
|
#include <footprint.h>
|
|
|
|
#include <pad.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_shape.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2023-10-23 17:23:24 +00:00
|
|
|
#include <pcb_reference_image.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
2022-01-30 10:52:52 +00:00
|
|
|
#include <pcb_textbox.h>
|
2024-01-15 17:29:55 +00:00
|
|
|
#include <pcb_table.h>
|
|
|
|
#include <pcb_tablecell.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <pcb_target.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
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.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 <pcb_painter.h>
|
2017-10-30 17:21:07 +00:00
|
|
|
#include <pcb_display_options.h>
|
2020-07-08 02:21:45 +00:00
|
|
|
#include <project/net_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2021-11-05 23:35:10 +00:00
|
|
|
#include <settings/common_settings.h>
|
2022-07-24 15:49:46 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2022-07-24 22:40:47 +00:00
|
|
|
#include <settings/cvpcb_settings.h>
|
2022-03-08 15:52:25 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2023-10-26 09:59:06 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
2017-10-30 17:21:07 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2022-03-08 15:52:25 +00:00
|
|
|
#include <callback_gal.h>
|
2019-05-14 12:39:34 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2018-12-19 18:53:27 +00:00
|
|
|
#include <geometry/shape_line_chain.h>
|
2020-10-14 14:55:06 +00:00
|
|
|
#include <geometry/shape_rect.h>
|
2020-06-22 19:35:09 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2020-10-14 14:55:06 +00:00
|
|
|
#include <geometry/shape_simple.h>
|
2020-06-22 19:35:09 +00:00
|
|
|
#include <geometry/shape_circle.h>
|
2021-11-04 12:56:14 +00:00
|
|
|
#include <bezier_curves.h>
|
2021-09-07 20:34:10 +00:00
|
|
|
#include <kiface_base.h>
|
2022-01-11 13:47:21 +00:00
|
|
|
#include <gr_text.h>
|
2021-11-05 23:35:10 +00:00
|
|
|
#include <pgm_base.h>
|
2019-06-04 07:23:12 +00:00
|
|
|
|
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
|
|
|
|
2022-07-23 08:34:31 +00:00
|
|
|
|
|
|
|
PCBNEW_SETTINGS* pcbconfig()
|
|
|
|
{
|
|
|
|
return dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helpers for display options existing in Cvpcb and Pcbnew
|
|
|
|
// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
|
|
|
|
// returns the viewer options existing to Cvpcb and Pcbnew
|
2022-07-24 22:40:47 +00:00
|
|
|
PCB_VIEWERS_SETTINGS_BASE* PCB_PAINTER::viewer_settings()
|
2022-07-23 08:34:31 +00:00
|
|
|
{
|
2022-07-24 22:40:47 +00:00
|
|
|
switch( m_frameType )
|
|
|
|
{
|
|
|
|
case FRAME_PCB_EDITOR:
|
|
|
|
case FRAME_PCB_DISPLAY3D:
|
|
|
|
default:
|
2022-07-24 15:49:46 +00:00
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
2022-07-23 08:34:31 +00:00
|
|
|
|
2023-10-26 09:59:06 +00:00
|
|
|
case FRAME_FOOTPRINT_EDITOR:
|
|
|
|
case FRAME_FOOTPRINT_WIZARD:
|
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
case FRAME_FOOTPRINT_VIEWER:
|
2023-09-26 17:31:45 +00:00
|
|
|
case FRAME_FOOTPRINT_CHOOSER:
|
2022-07-24 22:40:47 +00:00
|
|
|
case FRAME_FOOTPRINT_PREVIEW:
|
|
|
|
case FRAME_CVPCB:
|
|
|
|
case FRAME_CVPCB_DISPLAY:
|
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
|
|
|
|
}
|
2022-07-23 08:34:31 +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
|
|
|
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
|
|
|
|
{
|
2014-05-14 08:35:12 +00:00
|
|
|
m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
|
2021-12-26 00:36:12 +00:00
|
|
|
m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
|
2020-07-08 02:21:45 +00:00
|
|
|
m_netColorMode = NET_COLOR_MODE::RATSNEST;
|
2021-12-26 00:36:12 +00:00
|
|
|
m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
|
2014-05-14 08:35:12 +00:00
|
|
|
|
2022-02-08 19:29:54 +00:00
|
|
|
m_trackOpacity = 1.0;
|
|
|
|
m_viaOpacity = 1.0;
|
|
|
|
m_padOpacity = 1.0;
|
|
|
|
m_zoneOpacity = 1.0;
|
2022-06-27 18:07:52 +00:00
|
|
|
m_imageOpacity = 1.0;
|
2020-07-11 17:42:00 +00:00
|
|
|
|
2023-01-06 11:13:34 +00:00
|
|
|
m_ForcePadSketchModeOn = false;
|
|
|
|
|
|
|
|
m_PadEditModePad = nullptr;
|
2013-04-08 08:54:31 +00:00
|
|
|
|
2021-12-25 14:00:57 +00:00
|
|
|
SetDashLengthRatio( 12 ); // From ISO 128-2
|
|
|
|
SetGapLengthRatio( 3 ); // From ISO 128-2
|
2021-08-25 23:14:36 +00:00
|
|
|
|
2023-08-20 16:08:51 +00:00
|
|
|
m_ForceShowFieldsWhenFPSelected = true;
|
|
|
|
|
2013-08-07 07:51:39 +00:00
|
|
|
update();
|
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-01-13 01:44:19 +00:00
|
|
|
void PCB_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
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-01-13 01:44:19 +00:00
|
|
|
SetBackgroundColor( aSettings->GetColor( LAYER_PCB_BACKGROUND ) );
|
|
|
|
|
2017-04-05 14:29:53 +00:00
|
|
|
// Init board layers colors:
|
2017-03-13 03:19:33 +00:00
|
|
|
for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
|
2017-03-07 10:57:52 +00:00
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
m_layerColors[i] = aSettings->GetColor( i );
|
2017-07-04 10:48:47 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Guard: if the alpha channel is too small, the layer is not visible.
|
2017-07-04 10:48:47 +00:00
|
|
|
if( m_layerColors[i].a < 0.2 )
|
|
|
|
m_layerColors[i].a = 0.2;
|
2017-03-07 10:57:52 +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-04-05 14:29:53 +00:00
|
|
|
// Init specific graphic layers colors:
|
2017-03-13 03:19:33 +00:00
|
|
|
for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
|
2020-01-13 01:44:19 +00:00
|
|
|
m_layerColors[i] = aSettings->GetColor( i );
|
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-02 20:47:35 +00:00
|
|
|
// Colors for layers that aren't theme-able
|
2021-01-30 14:41:31 +00:00
|
|
|
m_layerColors[LAYER_PAD_PLATEDHOLES] = aSettings->GetColor( LAYER_PCB_BACKGROUND );
|
|
|
|
m_layerColors[LAYER_VIA_NETNAMES] = COLOR4D( 0.2, 0.2, 0.2, 0.9 );
|
|
|
|
m_layerColors[LAYER_PAD_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
|
2023-08-04 10:13:20 +00:00
|
|
|
m_layerColors[LAYER_PADS_SMD_FR] = aSettings->GetColor( F_Cu );
|
|
|
|
m_layerColors[LAYER_PADS_SMD_BK] = aSettings->GetColor( B_Cu );
|
2021-01-30 14:41:31 +00:00
|
|
|
m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
|
|
|
|
m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
|
2017-04-05 14:29:53 +00:00
|
|
|
|
2013-07-08 14:46:04 +00:00
|
|
|
// Netnames for copper layers
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
|
2013-07-08 14:46:04 +00:00
|
|
|
{
|
2021-10-24 10:14:54 +00:00
|
|
|
const COLOR4D lightLabel( 1.0, 1.0, 1.0, 0.7 );
|
2016-05-02 14:08:50 +00:00
|
|
|
const COLOR4D darkLabel = lightLabel.Inverted();
|
2021-02-02 20:47:35 +00:00
|
|
|
PCB_LAYER_ID layer = *cu;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2016-05-02 14:08:50 +00:00
|
|
|
if( m_layerColors[layer].GetBrightness() > 0.5 )
|
|
|
|
m_layerColors[GetNetnameLayer( layer )] = darkLabel;
|
|
|
|
else
|
|
|
|
m_layerColors[GetNetnameLayer( layer )] = lightLabel;
|
2013-07-08 14:46:04 +00:00
|
|
|
}
|
|
|
|
|
2022-02-14 17:57:58 +00:00
|
|
|
if( PgmOrNull() ) // can be null if used without project (i.e. from python script)
|
|
|
|
m_hiContrastFactor = 1.0f - Pgm().GetCommonSettings()->m_Appearance.hicontrast_dimming_factor;
|
|
|
|
else
|
|
|
|
m_hiContrastFactor = 1.0f - 0.8f; // default value
|
2021-11-05 23:35:10 +00:00
|
|
|
|
2013-08-07 07:51:39 +00:00
|
|
|
update();
|
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-09-07 20:34:10 +00:00
|
|
|
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
m_hiContrastEnabled = aOptions.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
|
2021-12-26 00:36:12 +00:00
|
|
|
m_ZoneDisplayMode = aOptions.m_ZoneDisplayMode;
|
|
|
|
m_ContrastModeDisplay = aOptions.m_ContrastModeDisplay;
|
|
|
|
m_netColorMode = aOptions.m_NetColorMode;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2022-02-08 19:29:54 +00:00
|
|
|
m_trackOpacity = aOptions.m_TrackOpacity;
|
|
|
|
m_viaOpacity = aOptions.m_ViaOpacity;
|
|
|
|
m_padOpacity = aOptions.m_PadOpacity;
|
|
|
|
m_zoneOpacity = aOptions.m_ZoneOpacity;
|
2022-06-27 18:07:52 +00:00
|
|
|
m_imageOpacity = aOptions.m_ImageOpacity;
|
2020-07-08 02:21:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
2023-07-10 22:15:17 +00:00
|
|
|
const BOARD_ITEM* item = dynamic_cast<const BOARD_ITEM*>( aItem );
|
|
|
|
const BOARD_CONNECTED_ITEM* conItem = dynamic_cast<const BOARD_CONNECTED_ITEM*>( aItem );
|
2021-01-30 14:41:31 +00:00
|
|
|
int netCode = -1;
|
|
|
|
int originalLayer = aLayer;
|
2013-06-25 15:12:54 +00:00
|
|
|
|
2023-08-20 15:29:09 +00:00
|
|
|
// Some graphic objects are BOARD_CONNECTED_ITEM, but they are seen here as
|
|
|
|
// actually board connected objects only if on a copper layer
|
|
|
|
if( conItem && !conItem->IsOnCopperLayer() )
|
|
|
|
conItem = nullptr;
|
|
|
|
|
2020-10-12 22:24:35 +00:00
|
|
|
// Marker shadows
|
|
|
|
if( aLayer == LAYER_MARKER_SHADOWS )
|
2020-11-25 15:45:00 +00:00
|
|
|
return m_backgroundColor.WithAlpha( 0.6 );
|
|
|
|
|
2021-02-02 15:36:45 +00:00
|
|
|
if( IsHoleLayer( aLayer ) && m_isPrinting )
|
2020-11-27 22:30:35 +00:00
|
|
|
{
|
2021-01-28 16:08:50 +00:00
|
|
|
// Careful that we don't end up with the same colour for the annular ring and the hole
|
|
|
|
// when printing in B&W.
|
2021-06-11 21:07:02 +00:00
|
|
|
const PAD* pad = dynamic_cast<const PAD*>( item );
|
|
|
|
const PCB_VIA* via = dynamic_cast<const PCB_VIA*>( item );
|
|
|
|
int holeLayer = aLayer;
|
|
|
|
int annularRingLayer = UNDEFINED_LAYER;
|
2020-11-27 22:30:35 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
if( pad && pad->GetAttribute() == PAD_ATTRIB::PTH )
|
2021-01-28 16:08:50 +00:00
|
|
|
annularRingLayer = LAYER_PADS_TH;
|
2021-01-31 14:11:24 +00:00
|
|
|
else if( via && via->GetViaType() == VIATYPE::MICROVIA )
|
2020-11-27 22:30:35 +00:00
|
|
|
annularRingLayer = LAYER_VIA_MICROVIA;
|
2021-01-31 14:11:24 +00:00
|
|
|
else if( via && via->GetViaType() == VIATYPE::BLIND_BURIED )
|
2020-11-27 22:30:35 +00:00
|
|
|
annularRingLayer = LAYER_VIA_BBLIND;
|
2021-03-18 23:20:35 +00:00
|
|
|
else if( via && via->GetViaType() == VIATYPE::THROUGH )
|
2020-11-27 22:30:35 +00:00
|
|
|
annularRingLayer = LAYER_VIA_THROUGH;
|
|
|
|
|
2021-03-18 23:20:35 +00:00
|
|
|
if( annularRingLayer != UNDEFINED_LAYER
|
|
|
|
&& m_layerColors[ holeLayer ] == m_layerColors[ annularRingLayer ] )
|
|
|
|
{
|
2020-11-25 15:45:00 +00:00
|
|
|
aLayer = LAYER_PCB_BACKGROUND;
|
2021-03-18 23:20:35 +00:00
|
|
|
}
|
2020-10-12 22:24:35 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 15:45:00 +00:00
|
|
|
// Zones should pull from the copper layer
|
2023-03-30 11:49:23 +00:00
|
|
|
if( item && item->Type() == PCB_ZONE_T )
|
2021-03-08 12:57:33 +00:00
|
|
|
{
|
2022-11-05 12:00:56 +00:00
|
|
|
if( IsZoneFillLayer( aLayer ) )
|
2021-03-08 12:57:33 +00:00
|
|
|
aLayer = aLayer - LAYER_ZONE_START;
|
|
|
|
}
|
2020-11-25 15:45:00 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
// Hole walls should pull from the copper layer
|
|
|
|
if( aLayer == LAYER_PAD_HOLEWALLS )
|
|
|
|
aLayer = LAYER_PADS_TH;
|
|
|
|
else if( aLayer == LAYER_VIA_HOLEWALLS )
|
|
|
|
aLayer = LAYER_VIA_THROUGH;
|
|
|
|
|
2023-07-10 22:15:17 +00:00
|
|
|
// Show via mask layers if appropriate
|
|
|
|
if( aLayer == LAYER_VIA_THROUGH && !m_isPrinting )
|
|
|
|
{
|
|
|
|
if( item && item->GetBoard() )
|
|
|
|
{
|
|
|
|
LSET visibleLayers = item->GetBoard()->GetVisibleLayers()
|
|
|
|
& item->GetBoard()->GetEnabledLayers()
|
|
|
|
& item->GetLayerSet();
|
|
|
|
|
|
|
|
if( GetActiveLayer() == F_Mask && visibleLayers.test( F_Mask ) )
|
|
|
|
aLayer = F_Mask;
|
|
|
|
else if( GetActiveLayer() == B_Mask && visibleLayers.test( B_Mask ) )
|
|
|
|
aLayer = B_Mask;
|
|
|
|
else if( ( visibleLayers & LSET::AllCuMask() ).none() )
|
2023-07-11 14:19:19 +00:00
|
|
|
{
|
|
|
|
if( visibleLayers.any() )
|
|
|
|
aLayer = visibleLayers.Seq().back();
|
|
|
|
}
|
2023-07-10 22:15:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Normal path: get the layer base color
|
|
|
|
COLOR4D color = m_layerColors[aLayer];
|
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
if( !item )
|
|
|
|
return m_layerColors[aLayer];
|
|
|
|
|
2020-11-25 15:45:00 +00:00
|
|
|
// Selection disambiguation
|
|
|
|
if( item->IsBrightened() )
|
|
|
|
return color.Brightened( m_selectFactor ).WithAlpha( 0.8 );
|
2017-09-20 19:56:22 +00:00
|
|
|
|
2020-11-25 15:45:00 +00:00
|
|
|
// Normal selection
|
|
|
|
if( item->IsSelected() )
|
|
|
|
color = m_layerColorsSel[aLayer];
|
2013-06-25 15:12:54 +00:00
|
|
|
|
2020-07-08 02:21:45 +00:00
|
|
|
// Try to obtain the netcode for the item
|
|
|
|
if( conItem )
|
|
|
|
netCode = conItem->GetNetCode();
|
|
|
|
|
2020-08-19 22:41:04 +00:00
|
|
|
bool highlighted = m_highlightEnabled && m_highlightNetcodes.count( netCode );
|
2020-10-13 00:32:25 +00:00
|
|
|
bool selected = item->IsSelected();
|
2020-08-19 22:41:04 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Apply net color overrides
|
2020-08-15 22:49:56 +00:00
|
|
|
if( conItem && m_netColorMode == NET_COLOR_MODE::ALL && IsNetCopperLayer( aLayer ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
2020-09-04 09:57:33 +00:00
|
|
|
COLOR4D netColor = COLOR4D::UNSPECIFIED;
|
2015-09-01 09:27:38 +00:00
|
|
|
|
2020-09-04 09:57:33 +00:00
|
|
|
auto ii = m_netColors.find( netCode );
|
|
|
|
|
|
|
|
if( ii != m_netColors.end() )
|
|
|
|
netColor = ii->second;
|
|
|
|
|
|
|
|
if( netColor == COLOR4D::UNSPECIFIED )
|
2020-08-19 22:41:04 +00:00
|
|
|
{
|
2020-09-04 09:57:33 +00:00
|
|
|
auto jj = m_netclassColors.find( conItem->GetNetClassName() );
|
|
|
|
|
|
|
|
if( jj != m_netclassColors.end() )
|
|
|
|
netColor = jj->second;
|
2020-08-19 22:41:04 +00:00
|
|
|
}
|
2020-09-04 09:57:33 +00:00
|
|
|
|
2020-09-07 15:51:55 +00:00
|
|
|
if( netColor == COLOR4D::UNSPECIFIED )
|
|
|
|
netColor = color;
|
2022-01-02 17:11:24 +00:00
|
|
|
|
|
|
|
if( selected )
|
2020-08-19 22:41:04 +00:00
|
|
|
{
|
2020-09-07 15:51:55 +00:00
|
|
|
// Selection brightening overrides highlighting
|
|
|
|
netColor.Brighten( m_selectFactor );
|
2020-08-19 22:41:04 +00:00
|
|
|
}
|
2020-09-07 15:51:55 +00:00
|
|
|
else if( m_highlightEnabled )
|
|
|
|
{
|
|
|
|
// Highlight brightens objects on all layers and darkens everything else for contrast
|
|
|
|
if( highlighted )
|
|
|
|
netColor.Brighten( m_highlightFactor );
|
|
|
|
else
|
|
|
|
netColor.Darken( 1.0 - m_highlightFactor );
|
|
|
|
}
|
|
|
|
|
|
|
|
color = netColor;
|
2020-08-15 22:49:56 +00:00
|
|
|
}
|
2020-10-13 00:32:25 +00:00
|
|
|
else if( !selected && m_highlightEnabled )
|
2020-08-15 22:49:56 +00:00
|
|
|
{
|
|
|
|
// Single net highlight mode
|
2020-08-19 22:41:04 +00:00
|
|
|
color = m_highlightNetcodes.count( netCode ) ? m_layerColorsHi[aLayer]
|
|
|
|
: m_layerColorsDark[aLayer];
|
2020-08-15 22:49:56 +00:00
|
|
|
}
|
2020-07-11 17:42:00 +00:00
|
|
|
|
2020-08-19 22:41:04 +00:00
|
|
|
// Apply high-contrast dimming
|
2021-04-13 12:33:02 +00:00
|
|
|
if( m_hiContrastEnabled && m_highContrastLayers.size() && !highlighted && !selected )
|
2020-11-04 02:05:02 +00:00
|
|
|
{
|
2020-11-05 00:22:15 +00:00
|
|
|
PCB_LAYER_ID primary = GetPrimaryHighContrastLayer();
|
|
|
|
bool isActive = m_highContrastLayers.count( aLayer );
|
2023-01-07 15:20:12 +00:00
|
|
|
bool hide = false;
|
2020-10-13 02:47:20 +00:00
|
|
|
|
2021-04-11 16:50:59 +00:00
|
|
|
switch( originalLayer )
|
2020-11-05 00:22:15 +00:00
|
|
|
{
|
2023-09-11 20:31:04 +00:00
|
|
|
case LAYER_PADS_SMD_FR:
|
|
|
|
case LAYER_PADS_SMD_BK:
|
2021-04-11 16:50:59 +00:00
|
|
|
case LAYER_PADS_TH:
|
2023-01-06 11:13:34 +00:00
|
|
|
{
|
|
|
|
const PAD* pad = static_cast<const PAD*>( item );
|
|
|
|
|
2023-11-10 13:57:23 +00:00
|
|
|
if( pad->IsOnLayer( primary ) && !pad->FlashLayer( primary ) )
|
2023-01-07 15:20:12 +00:00
|
|
|
{
|
2023-01-06 11:13:34 +00:00
|
|
|
isActive = false;
|
2023-01-11 18:15:07 +00:00
|
|
|
|
|
|
|
if( IsCopperLayer( primary ) )
|
|
|
|
hide = true;
|
2023-01-07 15:20:12 +00:00
|
|
|
}
|
2023-01-06 11:13:34 +00:00
|
|
|
|
|
|
|
if( m_PadEditModePad && pad != m_PadEditModePad )
|
2021-01-28 16:08:50 +00:00
|
|
|
isActive = false;
|
2021-04-11 16:50:59 +00:00
|
|
|
|
|
|
|
break;
|
2023-01-06 11:13:34 +00:00
|
|
|
}
|
2021-04-11 16:50:59 +00:00
|
|
|
|
|
|
|
case LAYER_VIA_BBLIND:
|
|
|
|
case LAYER_VIA_MICROVIA:
|
2023-01-06 11:13:34 +00:00
|
|
|
{
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
|
|
|
|
|
2021-04-11 16:50:59 +00:00
|
|
|
// Target graphic is active if the via crosses the primary layer
|
2023-01-06 11:13:34 +00:00
|
|
|
if( via->GetLayerSet().test( primary ) == 0 )
|
2023-01-07 15:20:12 +00:00
|
|
|
{
|
2021-04-11 16:50:59 +00:00
|
|
|
isActive = false;
|
2023-01-07 15:20:12 +00:00
|
|
|
hide = true;
|
|
|
|
}
|
2021-04-11 16:50:59 +00:00
|
|
|
|
|
|
|
break;
|
2023-01-06 11:13:34 +00:00
|
|
|
}
|
2021-04-11 16:50:59 +00:00
|
|
|
|
|
|
|
case LAYER_VIA_THROUGH:
|
2023-01-06 11:13:34 +00:00
|
|
|
{
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
|
|
|
|
|
|
|
|
if( !via->FlashLayer( primary ) )
|
2023-01-07 15:20:12 +00:00
|
|
|
{
|
2021-01-28 23:30:59 +00:00
|
|
|
isActive = false;
|
2023-01-11 18:15:07 +00:00
|
|
|
|
|
|
|
if( IsCopperLayer( primary ) )
|
|
|
|
hide = true;
|
2023-01-07 15:20:12 +00:00
|
|
|
}
|
2021-04-10 21:37:56 +00:00
|
|
|
|
2021-04-11 16:50:59 +00:00
|
|
|
break;
|
2023-01-06 11:13:34 +00:00
|
|
|
}
|
2021-04-11 16:50:59 +00:00
|
|
|
|
|
|
|
case LAYER_PAD_PLATEDHOLES:
|
|
|
|
case LAYER_PAD_HOLEWALLS:
|
|
|
|
case LAYER_NON_PLATEDHOLES:
|
|
|
|
// Pad holes are active is any physical layer is active
|
|
|
|
if( LSET::PhysicalLayersMask().test( primary ) == 0 )
|
|
|
|
isActive = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_VIA_HOLES:
|
|
|
|
case LAYER_VIA_HOLEWALLS:
|
2023-01-06 11:13:34 +00:00
|
|
|
{
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
|
|
|
|
|
|
|
|
if( via->GetViaType() == VIATYPE::BLIND_BURIED
|
|
|
|
|| via->GetViaType() == VIATYPE::MICROVIA )
|
2021-04-10 21:37:56 +00:00
|
|
|
{
|
|
|
|
// A blind or micro via's hole is active if it crosses the primary layer
|
2023-01-06 11:13:34 +00:00
|
|
|
if( via->GetLayerSet().test( primary ) == 0 )
|
2021-04-10 21:37:56 +00:00
|
|
|
isActive = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-11 16:50:59 +00:00
|
|
|
// A through via's hole is active if any physical layer is active
|
2021-04-10 21:37:56 +00:00
|
|
|
if( LSET::PhysicalLayersMask().test( primary ) == 0 )
|
|
|
|
isActive = false;
|
|
|
|
}
|
2021-04-11 16:50:59 +00:00
|
|
|
|
|
|
|
break;
|
2023-01-06 11:13:34 +00:00
|
|
|
}
|
2021-04-11 16:50:59 +00:00
|
|
|
|
2023-06-20 01:33:21 +00:00
|
|
|
case LAYER_DRC_ERROR:
|
|
|
|
case LAYER_DRC_WARNING:
|
|
|
|
case LAYER_DRC_EXCLUSION:
|
|
|
|
isActive = true;
|
|
|
|
break;
|
|
|
|
|
2021-04-11 16:50:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
2021-04-10 21:37:56 +00:00
|
|
|
}
|
2020-11-05 00:22:15 +00:00
|
|
|
|
|
|
|
if( !isActive )
|
|
|
|
{
|
2023-01-07 15:20:12 +00:00
|
|
|
if( m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN
|
|
|
|
|| IsNetnameLayer( aLayer )
|
|
|
|
|| hide )
|
|
|
|
{
|
2020-11-05 00:22:15 +00:00
|
|
|
color = COLOR4D::CLEAR;
|
2023-01-07 15:20:12 +00:00
|
|
|
}
|
2020-11-05 00:22:15 +00:00
|
|
|
else
|
2022-07-20 18:46:30 +00:00
|
|
|
{
|
2020-11-05 00:22:15 +00:00
|
|
|
color = color.Mix( m_layerColors[LAYER_PCB_BACKGROUND], m_hiContrastFactor );
|
2022-07-20 18:46:30 +00:00
|
|
|
|
2023-10-23 17:23:24 +00:00
|
|
|
// Reference images can't have their color mixed so just reduce the opacity a bit
|
|
|
|
// so they show through less
|
|
|
|
if( item->Type() == PCB_REFERENCE_IMAGE_T )
|
2022-07-20 18:46:30 +00:00
|
|
|
color.a *= m_hiContrastFactor;
|
|
|
|
}
|
2020-11-05 00:22:15 +00:00
|
|
|
}
|
2020-07-08 02:21:45 +00:00
|
|
|
}
|
2023-01-20 19:08:39 +00:00
|
|
|
else if( originalLayer == LAYER_VIA_BBLIND || originalLayer == LAYER_VIA_MICROVIA )
|
|
|
|
{
|
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( item );
|
|
|
|
const BOARD* board = via->GetBoard();
|
|
|
|
LSET visibleLayers = board->GetVisibleLayers() & board->GetEnabledLayers();
|
|
|
|
|
|
|
|
// Target graphic is visible if the via crosses a visible layer
|
|
|
|
if( ( via->GetLayerSet() & visibleLayers ).none() )
|
|
|
|
color = COLOR4D::CLEAR;
|
|
|
|
}
|
2020-07-08 02:21:45 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Apply per-type opacity overrides
|
|
|
|
if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
|
|
|
|
color.a *= m_trackOpacity;
|
|
|
|
else if( item->Type() == PCB_VIA_T )
|
|
|
|
color.a *= m_viaOpacity;
|
|
|
|
else if( item->Type() == PCB_PAD_T )
|
|
|
|
color.a *= m_padOpacity;
|
2023-05-11 14:57:44 +00:00
|
|
|
else if( item->Type() == PCB_ZONE_T && static_cast<const ZONE*>( item )->IsTeardropArea() )
|
|
|
|
color.a *= m_trackOpacity;
|
2023-03-30 11:49:23 +00:00
|
|
|
else if( item->Type() == PCB_ZONE_T )
|
2020-07-11 17:42:00 +00:00
|
|
|
color.a *= m_zoneOpacity;
|
2023-10-23 17:23:24 +00:00
|
|
|
else if( item->Type() == PCB_REFERENCE_IMAGE_T )
|
2022-06-27 18:07:52 +00:00
|
|
|
color.a *= m_imageOpacity;
|
2023-07-30 19:39:07 +00:00
|
|
|
else if( item->Type() == PCB_SHAPE_T && item->IsOnCopperLayer() )
|
|
|
|
color.a *= m_trackOpacity;
|
2020-07-11 17:42:00 +00:00
|
|
|
|
2023-03-11 12:42:58 +00:00
|
|
|
if( item->GetForcedTransparency() > 0.0 )
|
|
|
|
color = color.WithAlpha( color.a * ( 1.0 - item->GetForcedTransparency() ) );
|
2023-03-10 17:15:40 +00:00
|
|
|
|
2021-09-07 11:32:25 +00:00
|
|
|
// No special modifiers enabled
|
2020-07-11 17:42:00 +00:00
|
|
|
return color;
|
2013-09-11 09:39:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
bool PCB_RENDER_SETTINGS::GetShowPageLimits() const
|
|
|
|
{
|
2022-01-04 12:09:02 +00:00
|
|
|
return pcbconfig() && pcbconfig()->m_ShowPageLimits;
|
2021-09-07 20:34:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
PCB_PAINTER::PCB_PAINTER( GAL* aGal, FRAME_T aFrameType ) :
|
2021-09-07 11:32:25 +00:00
|
|
|
PAINTER( aGal ),
|
2022-07-24 22:40:47 +00:00
|
|
|
m_frameType( aFrameType ),
|
2021-09-07 11:32:25 +00:00
|
|
|
m_maxError( ARC_HIGH_DEF ),
|
2022-08-25 18:21:00 +00:00
|
|
|
m_holePlatingThickness( 0 ),
|
|
|
|
m_lockedShadowMargin( 0 )
|
2013-09-11 09:39:46 +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-02-07 10:21:26 +00:00
|
|
|
int PCB_PAINTER::getLineThickness( int aActualThickness ) const
|
|
|
|
{
|
|
|
|
// if items have 0 thickness, draw them with the outline
|
|
|
|
// width, otherwise respect the set value (which, no matter
|
|
|
|
// how small will produce something)
|
|
|
|
if( aActualThickness == 0 )
|
|
|
|
return m_pcbSettings.m_outlineWidth;
|
|
|
|
|
|
|
|
return aActualThickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
int PCB_PAINTER::getDrillShape( const PAD* aPad ) const
|
2018-09-28 21:45:48 +00:00
|
|
|
{
|
|
|
|
return aPad->GetDrillShape();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-12 14:23:46 +00:00
|
|
|
SHAPE_SEGMENT PCB_PAINTER::getPadHoleShape( const PAD* aPad ) const
|
2018-09-28 21:45:48 +00:00
|
|
|
{
|
2022-11-12 14:23:46 +00:00
|
|
|
SHAPE_SEGMENT segm = *aPad->GetEffectiveHoleShape().get();
|
|
|
|
return segm;
|
2018-09-28 21:45:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-12 14:23:46 +00:00
|
|
|
int PCB_PAINTER::getViaDrillSize( const PCB_VIA* aVia ) const
|
2018-09-28 21:45:48 +00:00
|
|
|
{
|
|
|
|
return aVia->GetDrillValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-18 15:01:23 +00:00
|
|
|
bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
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-09-06 20:50:28 +00:00
|
|
|
const BOARD_ITEM* item = dynamic_cast<const BOARD_ITEM*>( aItem );
|
2018-02-26 15:51:18 +00:00
|
|
|
|
|
|
|
if( !item )
|
|
|
|
return false;
|
2014-06-06 09:44:21 +00:00
|
|
|
|
2021-09-07 16:08:44 +00:00
|
|
|
if( const BOARD* board = item->GetBoard() )
|
|
|
|
{
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
|
|
|
|
m_maxError = bds.m_MaxError;
|
|
|
|
m_holePlatingThickness = bds.GetHolePlatingThickness();
|
2022-08-23 22:25:55 +00:00
|
|
|
m_lockedShadowMargin = bds.GetLineThickness( F_SilkS ) * 4;
|
2021-12-05 21:56:55 +00:00
|
|
|
|
|
|
|
if( item->GetParentFootprint() && !board->IsFootprintHolder() )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
FOOTPRINT* parentFP = item->GetParentFootprint();
|
2021-12-05 21:56:55 +00:00
|
|
|
|
2023-10-23 17:23:24 +00:00
|
|
|
// Never draw footprint reference images on board
|
|
|
|
if( item->Type() == PCB_REFERENCE_IMAGE_T )
|
2023-03-30 11:49:23 +00:00
|
|
|
{
|
2022-02-08 19:29:54 +00:00
|
|
|
return false;
|
2023-03-30 11:49:23 +00:00
|
|
|
}
|
2022-02-08 19:29:54 +00:00
|
|
|
else if( item->GetLayerSet().count() > 1 )
|
2021-12-05 21:56:55 +00:00
|
|
|
{
|
|
|
|
// For multi-layer objects, exclude only those layers that are private
|
|
|
|
if( IsPcbLayer( aLayer ) && parentFP->GetPrivateLayers().test( aLayer ) )
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-21 18:18:39 +00:00
|
|
|
else if( item->GetLayerSet().count() == 1 )
|
2021-12-05 21:56:55 +00:00
|
|
|
{
|
|
|
|
// For single-layer objects, exclude all layers including ancillary layers
|
|
|
|
// such as holes, netnames, etc.
|
2022-03-21 18:18:39 +00:00
|
|
|
PCB_LAYER_ID singleLayer = item->GetLayerSet().Seq()[0];
|
|
|
|
|
|
|
|
if( parentFP->GetPrivateLayers().test( singleLayer ) )
|
2021-12-05 21:56:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-09-07 16:08:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_maxError = ARC_HIGH_DEF;
|
|
|
|
m_holePlatingThickness = 0;
|
|
|
|
}
|
2021-09-06 20:50:28 +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
|
|
|
// the "cast" applied in here clarifies which overloaded draw() is called
|
2014-06-06 09:44:21 +00:00
|
|
|
switch( item->Type() )
|
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
|
|
|
{
|
|
|
|
case PCB_TRACE_T:
|
2021-06-11 21:07:02 +00:00
|
|
|
draw( static_cast<const PCB_TRACK*>( item ), aLayer );
|
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
|
|
|
break;
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
case PCB_ARC_T:
|
2021-06-11 21:07:02 +00:00
|
|
|
draw( static_cast<const PCB_ARC*>( item ), aLayer );
|
2019-05-17 00:13:21 +00:00
|
|
|
break;
|
|
|
|
|
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
|
|
|
case PCB_VIA_T:
|
2021-06-11 21:07:02 +00:00
|
|
|
draw( static_cast<const PCB_VIA*>( item ), aLayer );
|
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
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_PAD_T:
|
2020-11-12 22:30:02 +00:00
|
|
|
draw( static_cast<const PAD*>( item ), aLayer );
|
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
|
|
|
break;
|
|
|
|
|
2020-10-04 14:19:33 +00:00
|
|
|
case PCB_SHAPE_T:
|
2020-10-04 23:34:59 +00:00
|
|
|
draw( static_cast<const PCB_SHAPE*>( item ), aLayer );
|
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
|
|
|
break;
|
|
|
|
|
2023-10-23 17:23:24 +00:00
|
|
|
case PCB_REFERENCE_IMAGE_T:
|
|
|
|
draw( static_cast<const PCB_REFERENCE_IMAGE*>( item ), aLayer );
|
2022-02-08 19:29:54 +00:00
|
|
|
break;
|
|
|
|
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
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
|
|
|
case PCB_TEXT_T:
|
2020-10-04 23:34:59 +00:00
|
|
|
draw( static_cast<const PCB_TEXT*>( item ), aLayer );
|
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
|
|
|
break;
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
case PCB_TEXTBOX_T:
|
|
|
|
draw( static_cast<const PCB_TEXTBOX*>( item ), aLayer );
|
|
|
|
break;
|
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
case PCB_TABLE_T:
|
|
|
|
draw( static_cast<const PCB_TABLE*>( item ), aLayer );
|
|
|
|
break;
|
|
|
|
|
2020-11-13 12:21:02 +00:00
|
|
|
case PCB_FOOTPRINT_T:
|
2020-11-13 15:15:52 +00:00
|
|
|
draw( static_cast<const FOOTPRINT*>( item ), aLayer );
|
2014-07-09 13:02:56 +00:00
|
|
|
break;
|
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
case PCB_GROUP_T:
|
2020-08-12 11:23:30 +00:00
|
|
|
draw( static_cast<const PCB_GROUP*>( item ), aLayer );
|
2020-08-11 19:37:07 +00:00
|
|
|
break;
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
case PCB_ZONE_T:
|
|
|
|
draw( static_cast<const ZONE*>( item ), aLayer );
|
2019-10-26 15:49:29 +00:00
|
|
|
break;
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_ALIGNED_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_CENTER_T:
|
2021-07-13 18:46:33 +00:00
|
|
|
case PCB_DIM_RADIAL_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2020-09-12 20:09:40 +00:00
|
|
|
case PCB_DIM_LEADER_T:
|
2021-06-11 16:59:28 +00:00
|
|
|
draw( static_cast<const PCB_DIMENSION_BASE*>( item ), aLayer );
|
2013-04-03 09:19:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TARGET_T:
|
2014-09-10 15:18:42 +00:00
|
|
|
draw( static_cast<const PCB_TARGET*>( item ) );
|
2013-04-03 09:19:13 +00:00
|
|
|
break;
|
|
|
|
|
2014-03-19 12:42:46 +00:00
|
|
|
case PCB_MARKER_T:
|
2020-11-14 18:11:28 +00:00
|
|
|
draw( static_cast<const PCB_MARKER*>( item ), aLayer );
|
2014-03-24 16:20:23 +00:00
|
|
|
break;
|
2014-03-19 12:42:46 +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
|
|
|
default:
|
2013-06-25 15:12:54 +00:00
|
|
|
// Painter does not know how to draw the object
|
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
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-23 22:58:58 +00:00
|
|
|
// Draw bounding boxes after drawing objects so they can be seen.
|
2022-01-17 11:55:55 +00:00
|
|
|
if( m_pcbSettings.GetDrawBoundingBoxes() )
|
2021-06-23 22:58:58 +00:00
|
|
|
{
|
|
|
|
// Show bounding boxes of painted objects for debugging.
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I box = item->GetBoundingBox();
|
|
|
|
|
2021-06-23 22:58:58 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
2021-10-26 12:18:08 +00:00
|
|
|
{
|
2021-06-23 22:58:58 +00:00
|
|
|
m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
|
|
|
|
COLOR4D( MAGENTA ) );
|
2021-10-26 12:18:08 +00:00
|
|
|
}
|
2021-06-23 22:58:58 +00:00
|
|
|
else
|
2021-10-26 12:18:08 +00:00
|
|
|
{
|
2021-06-23 22:58:58 +00:00
|
|
|
m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
|
2021-10-26 12:18:08 +00:00
|
|
|
COLOR4D( 0.4, 0.4, 0.4, 1 ) );
|
|
|
|
}
|
2021-06-23 22:58:58 +00:00
|
|
|
|
2021-10-26 12:18:08 +00:00
|
|
|
m_gal->SetLineWidth( 1 );
|
2021-06-23 22:58:58 +00:00
|
|
|
m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
|
|
|
|
|
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 ) :
|
|
|
|
COLOR4D( CYAN ) );
|
|
|
|
|
|
|
|
const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
|
|
|
|
|
|
|
|
if( fp )
|
|
|
|
{
|
2022-03-14 15:52:12 +00:00
|
|
|
const SHAPE_POLY_SET& convex = fp->GetBoundingHull();
|
2021-06-23 22:58:58 +00:00
|
|
|
|
|
|
|
m_gal->DrawPolyline( convex.COutline( 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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
|
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-10-24 10:14:54 +00:00
|
|
|
VECTOR2I start( aTrack->GetStart() );
|
|
|
|
VECTOR2I end( aTrack->GetEnd() );
|
2022-04-08 16:40:13 +00:00
|
|
|
int track_width = aTrack->GetWidth();
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aTrack, aLayer );
|
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-30 14:41:31 +00:00
|
|
|
if( IsNetnameLayer( aLayer ) )
|
2013-04-08 08:54:31 +00:00
|
|
|
{
|
2022-02-12 16:32:55 +00:00
|
|
|
if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
|
2021-01-30 14:41:31 +00:00
|
|
|
return;
|
2013-07-08 07:57:23 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
if( aTrack->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
|
|
|
|
return;
|
2013-07-08 07:57:23 +00:00
|
|
|
|
2023-07-30 19:39:07 +00:00
|
|
|
SHAPE_SEGMENT trackShape( { aTrack->GetStart(), aTrack->GetEnd() }, aTrack->GetWidth() );
|
|
|
|
renderNetNameForSegment( trackShape, color, aTrack->GetUnescapedShortNetname() );
|
2021-01-30 14:41:31 +00:00
|
|
|
return;
|
2013-04-08 08:54:31 +00:00
|
|
|
}
|
2022-03-07 17:03:06 +00:00
|
|
|
else if( IsCopperLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
2013-04-08 08:54:31 +00:00
|
|
|
{
|
2013-07-08 07:57:23 +00:00
|
|
|
// Draw a regular track
|
2022-03-07 17:03:06 +00:00
|
|
|
bool outline_mode = pcbconfig()
|
|
|
|
&& !pcbconfig()->m_Display.m_DisplayPcbTrackFill
|
|
|
|
&& aLayer != LAYER_LOCKED_ITEM_SHADOW;
|
2013-07-08 18:42:46 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2019-01-20 09:03:15 +00:00
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetIsStroke( outline_mode );
|
|
|
|
m_gal->SetIsFill( not outline_mode );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
2014-07-09 13:10:32 +00:00
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
2022-08-23 22:25:55 +00:00
|
|
|
track_width = track_width + m_lockedShadowMargin;
|
2022-03-07 17:03:06 +00:00
|
|
|
|
2022-04-08 16:40:13 +00:00
|
|
|
m_gal->DrawSegment( start, end, track_width );
|
2021-01-30 14:41:31 +00:00
|
|
|
}
|
2017-01-24 16:58:11 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
// Clearance lines
|
2022-02-17 20:06:52 +00:00
|
|
|
if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
|
2022-03-07 17:03:06 +00:00
|
|
|
&& !m_pcbSettings.m_isPrinting && aLayer != LAYER_LOCKED_ITEM_SHADOW )
|
2021-01-30 14:41:31 +00:00
|
|
|
{
|
|
|
|
int clearance = aTrack->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
|
2020-09-26 23:11:07 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2022-04-08 16:40:13 +00:00
|
|
|
m_gal->DrawSegment( start, end, track_width + clearance * 2 );
|
2013-07-08 07:57:23 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-30 19:39:07 +00:00
|
|
|
void PCB_PAINTER::renderNetNameForSegment( const SHAPE_SEGMENT& aSeg, const COLOR4D& aColor,
|
|
|
|
const wxString& aNetName ) const
|
|
|
|
{
|
|
|
|
// When drawing netnames, clip the track to the viewport
|
|
|
|
BOX2D viewport;
|
|
|
|
VECTOR2D screenSize = m_gal->GetScreenPixelSize();
|
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
|
|
|
|
|
|
|
viewport.SetOrigin( VECTOR2D( matrix * VECTOR2D( 0, 0 ) ) );
|
|
|
|
viewport.SetEnd( VECTOR2D( matrix * screenSize ) );
|
|
|
|
viewport.Normalize();
|
|
|
|
|
|
|
|
BOX2I clipBox( viewport.GetOrigin(), viewport.GetSize() );
|
|
|
|
SEG visibleSeg( aSeg.GetSeg().A, aSeg.GetSeg().B );
|
|
|
|
|
|
|
|
ClipLine( &clipBox, visibleSeg.A.x, visibleSeg.A.y, visibleSeg.B.x, visibleSeg.B.y );
|
|
|
|
|
|
|
|
size_t num_char = aNetName.size();
|
|
|
|
|
|
|
|
// Check if the track is long enough to have a netname displayed
|
|
|
|
int seg_minlength = aSeg.GetWidth() * num_char;
|
|
|
|
|
|
|
|
if( visibleSeg.Length() < seg_minlength )
|
|
|
|
return;
|
|
|
|
|
|
|
|
double textSize = aSeg.GetWidth();
|
|
|
|
double penWidth = textSize / 12.0;
|
|
|
|
EDA_ANGLE textOrientation;
|
|
|
|
int num_names = 1;
|
|
|
|
|
|
|
|
VECTOR2I start = aSeg.GetSeg().A;
|
|
|
|
VECTOR2I end = aSeg.GetSeg().B;
|
|
|
|
|
|
|
|
if( end.y == start.y ) // horizontal
|
|
|
|
{
|
|
|
|
textOrientation = ANGLE_HORIZONTAL;
|
|
|
|
num_names = std::max( num_names,
|
|
|
|
static_cast<int>( aSeg.GetSeg().Length() / viewport.GetWidth() ) );
|
|
|
|
}
|
|
|
|
else if( end.x == start.x ) // vertical
|
|
|
|
{
|
|
|
|
textOrientation = ANGLE_VERTICAL;
|
|
|
|
num_names = std::max( num_names,
|
|
|
|
static_cast<int>( aSeg.GetSeg().Length() / viewport.GetHeight() ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
textOrientation = -EDA_ANGLE( visibleSeg.B - visibleSeg.A );
|
|
|
|
textOrientation.Normalize90();
|
|
|
|
|
|
|
|
double min_size = std::min( viewport.GetWidth(), viewport.GetHeight() );
|
|
|
|
num_names = std::max( num_names,
|
|
|
|
static_cast<int>( aSeg.GetSeg().Length() / ( M_SQRT2 * min_size ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetStrokeColor( aColor );
|
|
|
|
m_gal->SetLineWidth( penWidth );
|
|
|
|
m_gal->SetFontBold( false );
|
|
|
|
m_gal->SetFontItalic( false );
|
|
|
|
m_gal->SetFontUnderlined( false );
|
|
|
|
m_gal->SetTextMirrored( false );
|
|
|
|
m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
|
|
|
|
|
|
|
|
for( int ii = 0; ii < num_names; ++ii )
|
|
|
|
{
|
|
|
|
VECTOR2I textPosition =
|
|
|
|
VECTOR2D( start ) * static_cast<double>( num_names - ii ) / ( num_names + 1 )
|
|
|
|
+ VECTOR2D( end ) * static_cast<double>( ii + 1 ) / ( num_names + 1 );
|
|
|
|
|
|
|
|
if( clipBox.Contains( textPosition ) )
|
|
|
|
m_gal->BitmapText( aNetName, textPosition, textOrientation );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_ARC* aArc, int aLayer )
|
2019-05-17 00:13:21 +00:00
|
|
|
{
|
2022-01-14 15:34:41 +00:00
|
|
|
VECTOR2D center( aArc->GetCenter() );
|
|
|
|
int width = aArc->GetWidth();
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aArc, aLayer );
|
|
|
|
double radius = aArc->GetRadius();
|
|
|
|
EDA_ANGLE start_angle = aArc->GetArcAngleStart();
|
|
|
|
EDA_ANGLE angle = aArc->GetAngle();
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
if( IsNetnameLayer( aLayer ) )
|
|
|
|
{
|
|
|
|
// Ummm, yeah. Anyone fancy implementing text on a path?
|
|
|
|
return;
|
|
|
|
}
|
2022-03-07 17:03:06 +00:00
|
|
|
else if( IsCopperLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
2019-05-17 00:13:21 +00:00
|
|
|
{
|
|
|
|
// Draw a regular track
|
2022-03-07 17:03:06 +00:00
|
|
|
bool outline_mode = pcbconfig()
|
|
|
|
&& !pcbconfig()->m_Display.m_DisplayPcbTrackFill
|
|
|
|
&& aLayer != LAYER_LOCKED_ITEM_SHADOW;
|
2019-05-17 00:13:21 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetIsStroke( outline_mode );
|
|
|
|
m_gal->SetIsFill( not outline_mode );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
2022-08-23 22:25:55 +00:00
|
|
|
width = width + m_lockedShadowMargin;
|
2022-03-07 17:03:06 +00:00
|
|
|
|
2023-08-22 13:06:53 +00:00
|
|
|
m_gal->DrawArcSegment( center, radius, start_angle, angle, width, m_maxError );
|
2021-01-30 14:41:31 +00:00
|
|
|
}
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
// Clearance lines
|
2022-02-17 20:06:52 +00:00
|
|
|
if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
|
2022-03-07 17:03:06 +00:00
|
|
|
&& !m_pcbSettings.m_isPrinting && aLayer != LAYER_LOCKED_ITEM_SHADOW )
|
2021-01-30 14:41:31 +00:00
|
|
|
{
|
|
|
|
int clearance = aArc->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
|
2020-10-23 12:42:48 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2023-08-22 13:06:53 +00:00
|
|
|
m_gal->DrawArcSegment( center, radius, start_angle, angle, width + clearance * 2,
|
|
|
|
m_maxError );
|
2019-05-17 00:13:21 +00:00
|
|
|
}
|
2021-06-25 16:46:16 +00:00
|
|
|
|
|
|
|
// Debug only: enable this code only to test the TransformArcToPolygon function
|
|
|
|
// and display the polygon outline created by it.
|
2021-06-26 16:57:07 +00:00
|
|
|
// arcs on F_Cu are approximated with ERROR_INSIDE, others with ERROR_OUTSIDE
|
2021-06-25 16:46:16 +00:00
|
|
|
#if 0
|
|
|
|
SHAPE_POLY_SET cornerBuffer;
|
2021-06-26 16:57:07 +00:00
|
|
|
ERROR_LOC errorloc = aLayer == F_Cu ? ERROR_LOC::ERROR_INSIDE : ERROR_LOC::ERROR_OUTSIDE;
|
2021-09-06 20:50:28 +00:00
|
|
|
TransformArcToPolygon( cornerBuffer, aArc->GetStart(), aArc->GetMid(), aArc->GetEnd(), width,
|
|
|
|
m_maxError, errorloc );
|
2021-06-25 16:46:16 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2021-06-28 13:50:16 +00:00
|
|
|
m_gal->SetStrokeColor( COLOR4D( 0, 0, 1.0, 1.0 ) );
|
2021-06-25 16:46:16 +00:00
|
|
|
m_gal->DrawPolygon( cornerBuffer );
|
|
|
|
#endif
|
2021-06-28 13:50:16 +00:00
|
|
|
|
|
|
|
// Debug only: enable this code only to test the SHAPE_ARC::ConvertToPolyline function
|
|
|
|
// and display the polyline created by it.
|
|
|
|
#if 0
|
2023-11-18 19:06:00 +00:00
|
|
|
SHAPE_ARC arc( aArc->GetCenter(), aArc->GetStart(), aArc->GetAngle(), aArc->GetWidth() );
|
2021-09-06 20:50:28 +00:00
|
|
|
SHAPE_LINE_CHAIN arcSpine = arc.ConvertToPolyline( m_maxError );
|
2021-06-28 13:50:16 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( COLOR4D( 0.3, 0.2, 0.5, 1.0 ) );
|
|
|
|
|
|
|
|
for( int idx = 1; idx < arcSpine.PointCount(); idx++ )
|
2021-09-06 20:50:28 +00:00
|
|
|
m_gal->DrawSegment( arcSpine.CPoint( idx-1 ), arcSpine.CPoint( idx ), aArc->GetWidth() );
|
2021-06-28 13:50:16 +00:00
|
|
|
#endif
|
2019-05-17 00:13:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
|
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
|
|
|
{
|
2022-10-18 12:00:37 +00:00
|
|
|
const BOARD* board = aVia->GetBoard();
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer );
|
|
|
|
VECTOR2D center( aVia->GetStart() );
|
2021-01-30 14:41:31 +00:00
|
|
|
|
|
|
|
if( color == COLOR4D::CLEAR )
|
|
|
|
return;
|
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-04-25 09:47:21 +00:00
|
|
|
// Draw description layer
|
|
|
|
if( IsNetnameLayer( aLayer ) )
|
|
|
|
{
|
|
|
|
VECTOR2D position( center );
|
2017-04-22 15:45:03 +00:00
|
|
|
|
2023-01-18 08:56:25 +00:00
|
|
|
// Is anything that we can display enabled (netname and/or layers ids)?
|
|
|
|
bool showNets = pcbconfig() && pcbconfig()->m_Display.m_NetNames != 0
|
|
|
|
&& !aVia->GetNetname().empty();
|
|
|
|
bool showLayers = aVia->GetViaType() != VIATYPE::THROUGH;
|
2022-01-04 12:09:02 +00:00
|
|
|
|
2023-01-18 08:56:25 +00:00
|
|
|
if( !showNets && !showLayers )
|
2020-10-13 02:47:20 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
|
|
|
|
double size = aVia->GetWidth();
|
2017-04-22 15:45:03 +00:00
|
|
|
|
2020-10-13 02:47:20 +00:00
|
|
|
// Font size limits
|
|
|
|
if( size > maxSize )
|
|
|
|
size = maxSize;
|
2017-04-25 09:47:21 +00:00
|
|
|
|
2020-10-13 02:47:20 +00:00
|
|
|
m_gal->Save();
|
|
|
|
m_gal->Translate( position );
|
2017-04-22 15:45:03 +00:00
|
|
|
|
2020-10-13 02:47:20 +00:00
|
|
|
// Default font settings
|
|
|
|
m_gal->ResetTextAttributes();
|
2022-07-15 18:40:27 +00:00
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
|
|
|
|
m_gal->SetFontBold( false );
|
|
|
|
m_gal->SetFontItalic( false );
|
|
|
|
m_gal->SetFontUnderlined( false );
|
|
|
|
m_gal->SetTextMirrored( false );
|
2021-07-19 23:56:05 +00:00
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( nullptr, aLayer ) );
|
2022-07-15 18:40:27 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2017-04-22 15:45:03 +00:00
|
|
|
|
2023-01-18 08:56:25 +00:00
|
|
|
// Set the text position via position. if only one text, it is on the via position
|
|
|
|
// For 2 lines, the netname is slightly below the center, and the layer IDs above
|
|
|
|
// the netname
|
2020-10-13 02:47:20 +00:00
|
|
|
VECTOR2D textpos( 0.0, 0.0 );
|
|
|
|
|
2023-01-27 15:37:36 +00:00
|
|
|
wxString netname = aVia->GetUnescapedShortNetname();
|
2021-06-23 22:58:58 +00:00
|
|
|
|
2023-01-18 08:56:25 +00:00
|
|
|
int topLayer = aVia->TopLayer() + 1;
|
|
|
|
int bottomLayer = std::min( aVia->BottomLayer() + 1, board->GetCopperLayerCount() );
|
|
|
|
|
|
|
|
wxString layerIds;
|
|
|
|
layerIds.Printf( wxT( "%d-%d" ), topLayer, bottomLayer );
|
|
|
|
|
|
|
|
// a good size is set room for at least 6 chars, to be able to print 2 lines of text,
|
|
|
|
// or at least 3 chars for only the netname
|
|
|
|
// (The layerIds string has 5 chars max)
|
|
|
|
int minCharCnt = showLayers ? 6 : 3;
|
|
|
|
|
|
|
|
// approximate the size of netname and layerIds text:
|
|
|
|
double tsize = 1.5 * size / std::max( PrintableCharCount( netname ), minCharCnt );
|
2020-10-13 02:47:20 +00:00
|
|
|
tsize = std::min( tsize, size );
|
2021-06-23 22:58:58 +00:00
|
|
|
|
2020-10-13 02:47:20 +00:00
|
|
|
// Use a smaller text size to handle interline, pen size..
|
2022-03-07 17:41:46 +00:00
|
|
|
tsize *= 0.75;
|
2020-10-13 02:47:20 +00:00
|
|
|
VECTOR2D namesize( tsize, tsize );
|
|
|
|
|
2023-01-18 08:56:25 +00:00
|
|
|
// For 2 lines, adjust the text pos (move it a small amount to the bottom)
|
|
|
|
if( showLayers )
|
|
|
|
textpos.y += tsize/5;
|
|
|
|
|
2020-10-13 02:47:20 +00:00
|
|
|
m_gal->SetGlyphSize( namesize );
|
2023-01-18 08:56:25 +00:00
|
|
|
m_gal->SetLineWidth( namesize.x / 10.0 );
|
|
|
|
|
|
|
|
if( showNets )
|
|
|
|
m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
|
|
|
|
|
|
|
|
if( showLayers )
|
|
|
|
{
|
|
|
|
if( showNets )
|
|
|
|
textpos.y -= tsize * 1.3;
|
|
|
|
|
|
|
|
m_gal->BitmapText( layerIds, textpos, ANGLE_HORIZONTAL );
|
|
|
|
}
|
2020-10-13 02:47:20 +00:00
|
|
|
|
|
|
|
m_gal->Restore();
|
2020-10-13 15:34:38 +00:00
|
|
|
|
|
|
|
return;
|
2017-04-25 09:47:21 +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
|
|
|
|
2022-03-15 21:57:09 +00:00
|
|
|
bool outline_mode = pcbconfig() && !pcbconfig()->m_Display.m_DisplayViaFill;
|
2021-01-30 14:41:31 +00:00
|
|
|
|
2022-03-15 21:57:09 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2020-10-13 02:47:20 +00:00
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2019-11-16 14:04:45 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
2022-03-15 21:57:09 +00:00
|
|
|
|
|
|
|
if( aLayer == LAYER_VIA_HOLEWALLS )
|
2019-11-16 14:04:45 +00:00
|
|
|
{
|
2022-11-12 14:23:46 +00:00
|
|
|
double radius = ( getViaDrillSize( aVia ) / 2.0 ) + m_holePlatingThickness;
|
2019-11-16 14:04:45 +00:00
|
|
|
|
2022-03-15 21:57:09 +00:00
|
|
|
if( !outline_mode )
|
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( m_holePlatingThickness );
|
|
|
|
radius -= m_holePlatingThickness / 2.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gal->DrawCircle( center, radius );
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_VIA_HOLES )
|
2021-01-30 14:41:31 +00:00
|
|
|
{
|
2022-03-15 21:57:09 +00:00
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetIsFill( true );
|
2022-11-12 14:23:46 +00:00
|
|
|
m_gal->DrawCircle( center, getViaDrillSize( aVia ) / 2.0 );
|
2021-01-30 14:41:31 +00:00
|
|
|
}
|
2023-07-11 09:07:37 +00:00
|
|
|
else if( ( aLayer == F_Mask && aVia->IsOnLayer( F_Mask ) )
|
|
|
|
|| ( aLayer == B_Mask && aVia->IsOnLayer( B_Mask ) ) )
|
|
|
|
{
|
|
|
|
int margin = board->GetDesignSettings().m_SolderMaskExpansion;
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
|
|
|
|
m_gal->SetLineWidth( margin );
|
2023-07-11 15:35:30 +00:00
|
|
|
m_gal->DrawCircle( center, aVia->GetWidth() / 2.0 + margin );
|
2023-07-11 09:07:37 +00:00
|
|
|
}
|
2022-06-19 10:57:29 +00:00
|
|
|
else if( aLayer == LAYER_VIA_THROUGH || m_pcbSettings.IsPrinting() )
|
2021-01-28 16:08:50 +00:00
|
|
|
{
|
2022-11-12 14:23:46 +00:00
|
|
|
int annular_width = ( aVia->GetWidth() - getViaDrillSize( aVia ) ) / 2.0;
|
2022-03-15 21:57:09 +00:00
|
|
|
double radius = aVia->GetWidth() / 2.0;
|
2022-10-18 12:00:37 +00:00
|
|
|
bool draw = false;
|
2022-06-19 10:57:29 +00:00
|
|
|
|
|
|
|
if( m_pcbSettings.IsPrinting() )
|
2022-10-18 12:00:37 +00:00
|
|
|
{
|
2022-06-19 10:57:29 +00:00
|
|
|
draw = aVia->FlashLayer( m_pcbSettings.GetPrintLayers() );
|
2022-10-18 12:00:37 +00:00
|
|
|
}
|
|
|
|
else if( aVia->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
|
|
|
|
{
|
|
|
|
draw = true;
|
|
|
|
}
|
|
|
|
else if( aVia->IsSelected() )
|
|
|
|
{
|
|
|
|
draw = true;
|
|
|
|
outline_mode = true;
|
2022-10-18 13:41:27 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
2022-10-18 12:00:37 +00:00
|
|
|
}
|
2022-03-15 21:57:09 +00:00
|
|
|
|
|
|
|
if( !outline_mode )
|
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( annular_width );
|
|
|
|
radius -= annular_width / 2.0;
|
|
|
|
}
|
|
|
|
|
2022-06-19 10:57:29 +00:00
|
|
|
if( draw )
|
|
|
|
m_gal->DrawCircle( center, radius );
|
2021-01-28 16:08:50 +00:00
|
|
|
}
|
2021-01-30 14:41:31 +00:00
|
|
|
else if( aLayer == LAYER_VIA_BBLIND || aLayer == LAYER_VIA_MICROVIA )
|
2014-08-06 11:53:02 +00:00
|
|
|
{
|
2022-11-12 14:23:46 +00:00
|
|
|
int annular_width = ( aVia->GetWidth() - getViaDrillSize( aVia ) ) / 2.0;
|
2022-03-15 21:57:09 +00:00
|
|
|
double radius = aVia->GetWidth() / 2.0;
|
|
|
|
|
2020-05-11 14:21:39 +00:00
|
|
|
// Outer circles of blind/buried and micro-vias are drawn in a special way to indicate the
|
2019-11-18 23:42:39 +00:00
|
|
|
// top and bottom layers
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layerTop, layerBottom;
|
2014-08-06 11:53:02 +00:00
|
|
|
aVia->LayerPair( &layerTop, &layerBottom );
|
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
if( !outline_mode )
|
2022-03-15 21:57:09 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
}
|
2019-11-16 14:04:45 +00:00
|
|
|
|
2022-03-15 21:57:09 +00:00
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerTop ) );
|
|
|
|
m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerTop ) );
|
2023-08-22 13:06:53 +00:00
|
|
|
m_gal->DrawArc( center, radius, EDA_ANGLE( 240, DEGREES_T ), EDA_ANGLE( 60, DEGREES_T ) );
|
2020-11-03 17:28:09 +00:00
|
|
|
|
2022-03-15 21:57:09 +00:00
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
|
|
|
|
m_gal->SetFillColor( m_pcbSettings.GetColor( aVia, layerBottom ) );
|
2023-08-22 13:06:53 +00:00
|
|
|
m_gal->DrawArc( center, radius, EDA_ANGLE( 60, DEGREES_T ), EDA_ANGLE( 60, DEGREES_T ) );
|
2017-01-24 16:58:11 +00:00
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2022-03-15 21:57:09 +00:00
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
2022-03-07 17:03:06 +00:00
|
|
|
|
2022-03-15 21:57:09 +00:00
|
|
|
if( !outline_mode )
|
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( annular_width );
|
|
|
|
radius -= annular_width / 2.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gal->DrawCircle( center, radius );
|
|
|
|
}
|
|
|
|
else if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // draw a ring around the via
|
|
|
|
{
|
2022-08-23 22:25:55 +00:00
|
|
|
m_gal->SetLineWidth( m_lockedShadowMargin );
|
2022-03-07 17:03:06 +00:00
|
|
|
|
2022-08-23 22:25:55 +00:00
|
|
|
m_gal->DrawCircle( center, ( aVia->GetWidth() + m_lockedShadowMargin ) / 2.0 );
|
2022-03-07 17:03:06 +00:00
|
|
|
}
|
|
|
|
|
2017-01-24 16:58:11 +00:00
|
|
|
// Clearance lines
|
2022-02-12 16:32:55 +00:00
|
|
|
if( pcbconfig() && pcbconfig()->m_Display.m_TrackClearance == SHOW_WITH_VIA_ALWAYS
|
2022-02-17 20:06:52 +00:00
|
|
|
&& aLayer != LAYER_VIA_HOLES
|
|
|
|
&& !m_pcbSettings.m_isPrinting )
|
2017-01-24 16:58:11 +00:00
|
|
|
{
|
2020-10-12 17:40:03 +00:00
|
|
|
PCB_LAYER_ID activeLayer = m_pcbSettings.GetActiveLayer();
|
2021-01-30 14:41:31 +00:00
|
|
|
double radius;
|
2020-10-12 17:40:03 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
if( aVia->FlashLayer( activeLayer ) )
|
|
|
|
radius = aVia->GetWidth() / 2.0;
|
|
|
|
else
|
2022-11-12 14:23:46 +00:00
|
|
|
radius = getViaDrillSize( aVia ) / 2.0 + m_holePlatingThickness;
|
2020-10-03 12:44:38 +00:00
|
|
|
|
2017-01-24 16:58:11 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2020-10-12 17:40:03 +00:00
|
|
|
m_gal->DrawCircle( center, radius + aVia->GetOwnClearance( activeLayer ) );
|
2017-01-24 16:58:11 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
|
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
|
|
|
{
|
2022-10-18 12:00:37 +00:00
|
|
|
const BOARD* board = aPad->GetBoard();
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer );
|
2021-01-30 14:41:31 +00:00
|
|
|
|
2013-07-16 11:40:53 +00:00
|
|
|
if( IsNetnameLayer( aLayer ) )
|
2013-07-08 09:30:50 +00:00
|
|
|
{
|
2022-07-23 08:34:31 +00:00
|
|
|
PCBNEW_SETTINGS::DISPLAY_OPTIONS* displayOpts = pcbconfig() ? &pcbconfig()->m_Display : nullptr;
|
2022-03-02 18:04:06 +00:00
|
|
|
wxString netname;
|
|
|
|
wxString padNumber;
|
2021-09-07 20:34:10 +00:00
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
if( viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers )
|
2022-07-24 15:49:46 +00:00
|
|
|
{
|
2022-03-02 18:04:06 +00:00
|
|
|
padNumber = UnescapeString( aPad->GetNumber() );
|
2021-09-07 20:34:10 +00:00
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
|
2024-03-09 11:58:23 +00:00
|
|
|
netname = aPad->GetPinFunction();
|
2022-07-24 15:49:46 +00:00
|
|
|
}
|
|
|
|
|
2024-03-09 11:58:23 +00:00
|
|
|
if( displayOpts && !dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
|
2013-07-08 11:57:09 +00:00
|
|
|
{
|
2022-07-23 08:34:31 +00:00
|
|
|
if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
|
2023-01-27 15:37:36 +00:00
|
|
|
netname = aPad->GetUnescapedShortNetname();
|
2022-07-23 08:34:31 +00:00
|
|
|
|
2022-09-07 10:07:00 +00:00
|
|
|
if( aPad->IsNoConnectPad() )
|
|
|
|
netname = wxT( "x" );
|
|
|
|
else if( aPad->IsFreePad() )
|
|
|
|
netname = wxT( "*" );
|
2022-03-02 18:04:06 +00:00
|
|
|
}
|
2020-08-04 16:53:36 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
if( netname.IsEmpty() && padNumber.IsEmpty() )
|
|
|
|
return;
|
2013-07-17 11:38:56 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
BOX2I padBBox = aPad->GetBoundingBox();
|
2022-03-02 18:04:06 +00:00
|
|
|
VECTOR2D position = padBBox.Centre();
|
|
|
|
VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
|
2020-06-29 11:48:55 +00:00
|
|
|
|
2023-09-01 17:46:51 +00:00
|
|
|
if( aPad->IsEntered() )
|
2022-09-14 10:34:10 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
FOOTPRINT* fp = aPad->GetParentFootprint();
|
2022-09-14 10:34:10 +00:00
|
|
|
|
|
|
|
// Find the number box
|
|
|
|
for( const BOARD_ITEM* aItem : fp->GraphicalItems() )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( aItem->Type() == PCB_SHAPE_T )
|
2022-09-14 10:34:10 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
|
2022-09-14 10:34:10 +00:00
|
|
|
|
2023-09-13 10:27:04 +00:00
|
|
|
if( shape->IsProxyItem() && shape->GetShape() == SHAPE_T::RECTANGLE )
|
2022-09-14 10:34:10 +00:00
|
|
|
{
|
|
|
|
position = shape->GetCenter();
|
|
|
|
padsize = shape->GetBotRight() - shape->GetTopLeft();
|
|
|
|
|
|
|
|
// We normally draw a bit outside the pad, but this will be somewhat
|
|
|
|
// unexpected when the user has drawn a box.
|
|
|
|
padsize *= 0.9;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
|
|
|
|
{
|
|
|
|
// See if we have a number box
|
|
|
|
for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
|
|
|
|
{
|
2023-09-13 10:27:04 +00:00
|
|
|
if( primitive->IsProxyItem() && primitive->GetShape() == SHAPE_T::RECTANGLE )
|
2022-09-14 10:34:10 +00:00
|
|
|
{
|
2023-09-13 17:27:00 +00:00
|
|
|
position = primitive->GetCenter();
|
|
|
|
RotatePoint( position, aPad->GetOrientation() );
|
|
|
|
position += aPad->ShapePos();
|
|
|
|
|
2022-09-20 23:16:00 +00:00
|
|
|
padsize.x = abs( primitive->GetBotRight().x - primitive->GetTopLeft().x );
|
|
|
|
padsize.y = abs( primitive->GetBotRight().y - primitive->GetTopLeft().y );
|
2022-09-14 10:34:10 +00:00
|
|
|
|
|
|
|
// We normally draw a bit outside the pad, but this will be somewhat
|
|
|
|
// unexpected when the user has drawn a box.
|
|
|
|
padsize *= 0.9;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
if( aPad->GetShape() != PAD_SHAPE::CUSTOM )
|
|
|
|
{
|
|
|
|
// Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
|
|
|
|
double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1;
|
2013-07-08 09:30:50 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
if( padsize.x > limit && padsize.y > limit )
|
2013-07-17 11:38:56 +00:00
|
|
|
{
|
2022-03-02 18:04:06 +00:00
|
|
|
padsize.x = limit;
|
|
|
|
padsize.y = limit;
|
2013-11-04 17:18:19 +00:00
|
|
|
}
|
2022-03-02 18:04:06 +00:00
|
|
|
}
|
2013-11-03 14:06:16 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
|
|
|
|
double size = padsize.y;
|
2013-11-04 17:18:19 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
m_gal->Save();
|
|
|
|
m_gal->Translate( position );
|
2021-09-04 21:08:52 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
// Keep the size ratio for the font, but make it smaller
|
2022-09-20 23:16:00 +00:00
|
|
|
if( padsize.x < ( padsize.y * 0.95 ) )
|
2022-03-02 18:04:06 +00:00
|
|
|
{
|
|
|
|
m_gal->Rotate( -ANGLE_90.AsRadians() );
|
|
|
|
size = padsize.x;
|
|
|
|
std::swap( padsize.x, padsize.y );
|
|
|
|
}
|
2021-06-23 22:58:58 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
// Font size limits
|
|
|
|
if( size > maxSize )
|
|
|
|
size = maxSize;
|
2013-11-03 14:06:16 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
// Default font settings
|
2022-07-15 18:40:27 +00:00
|
|
|
m_gal->ResetTextAttributes();
|
2022-03-02 18:04:06 +00:00
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER );
|
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER );
|
|
|
|
m_gal->SetFontBold( false );
|
|
|
|
m_gal->SetFontItalic( false );
|
|
|
|
m_gal->SetFontUnderlined( false );
|
|
|
|
m_gal->SetTextMirrored( false );
|
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
|
|
|
|
// We have already translated the GAL to be centered at the center of the pad's
|
|
|
|
// bounding box
|
|
|
|
VECTOR2I textpos( 0, 0 );
|
|
|
|
|
|
|
|
// Divide the space, to display both pad numbers and netnames and set the Y text
|
2023-02-25 10:05:21 +00:00
|
|
|
// offset position to display 2 lines
|
|
|
|
int Y_offset_numpad = 0;
|
|
|
|
int Y_offset_netname = 0;
|
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
if( !netname.IsEmpty() && !padNumber.IsEmpty() )
|
|
|
|
{
|
2023-02-25 10:05:21 +00:00
|
|
|
// The magic numbers are defined experimentally for a better look.
|
|
|
|
size = size / 2.5;
|
|
|
|
Y_offset_netname = size / 1.4; // netname size is usually smaller than num pad
|
|
|
|
// so the offset can be smaller
|
|
|
|
Y_offset_numpad = size / 1.7;
|
2022-03-02 18:04:06 +00:00
|
|
|
}
|
|
|
|
|
2023-02-25 10:05:21 +00:00
|
|
|
// We are using different fonts to display names, depending on the graphic
|
|
|
|
// engine (OpenGL or Cairo).
|
|
|
|
// Xscale_for_stroked_font adjust the text X size for cairo (stroke fonts) engine
|
|
|
|
const double Xscale_for_stroked_font = 0.9;
|
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
if( !netname.IsEmpty() )
|
|
|
|
{
|
|
|
|
// approximate the size of net name text:
|
2023-02-25 10:05:21 +00:00
|
|
|
// We use a size for at least 5 chars, to give a good look even for short names
|
|
|
|
// (like VCC, GND...)
|
|
|
|
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname )+1, 5 );
|
2022-03-02 18:04:06 +00:00
|
|
|
tsize = std::min( tsize, size );
|
|
|
|
|
|
|
|
// Use a smaller text size to handle interline, pen size...
|
2022-07-24 22:40:47 +00:00
|
|
|
tsize *= 0.85;
|
2023-02-25 10:05:21 +00:00
|
|
|
|
|
|
|
// Round and oval pads have less room to display the net name than other
|
|
|
|
// (i.e RECT) shapes, so reduce the text size for these shapes
|
|
|
|
if( aPad->GetShape() == PAD_SHAPE::CIRCLE || aPad->GetShape() == PAD_SHAPE::OVAL )
|
|
|
|
tsize *= 0.9;
|
|
|
|
|
|
|
|
VECTOR2D namesize( tsize*Xscale_for_stroked_font, tsize );
|
|
|
|
textpos.y = std::min( tsize * 1.4, double( Y_offset_netname ) );
|
2022-03-02 18:04:06 +00:00
|
|
|
|
|
|
|
m_gal->SetGlyphSize( namesize );
|
2022-07-24 22:40:47 +00:00
|
|
|
m_gal->SetLineWidth( namesize.x / 6.0 );
|
|
|
|
m_gal->SetFontBold( true );
|
2022-03-02 18:04:06 +00:00
|
|
|
m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
|
|
|
|
}
|
2013-07-17 11:38:56 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
if( !padNumber.IsEmpty() )
|
|
|
|
{
|
|
|
|
// approximate the size of the pad number text:
|
2023-02-25 10:05:21 +00:00
|
|
|
// We use a size for at least 3 chars, to give a good look even for short numbers
|
|
|
|
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 3 );
|
2022-03-02 18:04:06 +00:00
|
|
|
tsize = std::min( tsize, size );
|
|
|
|
|
|
|
|
// Use a smaller text size to handle interline, pen size...
|
2022-07-24 22:40:47 +00:00
|
|
|
tsize *= 0.85;
|
2022-03-02 18:04:06 +00:00
|
|
|
tsize = std::min( tsize, size );
|
2023-02-25 10:05:21 +00:00
|
|
|
VECTOR2D numsize( tsize*Xscale_for_stroked_font, tsize );
|
|
|
|
textpos.y = -Y_offset_numpad;
|
2022-03-02 18:04:06 +00:00
|
|
|
|
|
|
|
m_gal->SetGlyphSize( numsize );
|
2022-07-24 22:40:47 +00:00
|
|
|
m_gal->SetLineWidth( numsize.x / 6.0 );
|
|
|
|
m_gal->SetFontBold( true );
|
2022-03-02 18:04:06 +00:00
|
|
|
m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
|
2013-07-17 11:38:56 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-03-02 18:04:06 +00:00
|
|
|
m_gal->Restore();
|
|
|
|
|
2013-07-08 09:30:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-30 14:41:31 +00:00
|
|
|
else if( aLayer == LAYER_PAD_HOLEWALLS )
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2021-09-06 20:50:28 +00:00
|
|
|
m_gal->SetLineWidth( m_holePlatingThickness );
|
2021-01-30 14:41:31 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
|
|
|
|
int holeSize = slot->GetWidth() + m_holePlatingThickness;
|
2021-01-30 14:41:31 +00:00
|
|
|
|
2022-07-22 22:05:25 +00:00
|
|
|
if( slot->GetSeg().A == slot->GetSeg().B ) // Circular hole
|
|
|
|
m_gal->DrawCircle( slot->GetSeg().A, KiROUND( holeSize / 2.0 ) );
|
2021-01-30 14:41:31 +00:00
|
|
|
else
|
2022-07-22 22:05:25 +00:00
|
|
|
m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, holeSize );
|
2021-01-30 14:41:31 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2017-01-24 16:58:11 +00:00
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
|
2021-12-26 00:36:12 +00:00
|
|
|
|
2022-12-28 14:18:55 +00:00
|
|
|
if( m_pcbSettings.m_ForcePadSketchModeOn )
|
2021-12-26 00:36:12 +00:00
|
|
|
outline_mode = true;
|
|
|
|
|
|
|
|
if( outline_mode )
|
2013-04-08 08:54:31 +00:00
|
|
|
{
|
|
|
|
// Outline mode
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2014-05-21 21:13:30 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
2013-04-08 08:54:31 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Filled mode
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
}
|
|
|
|
|
2022-10-18 12:00:37 +00:00
|
|
|
bool drawShape = false;
|
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
if( aLayer == LAYER_PAD_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES )
|
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
|
|
|
{
|
2022-11-12 14:23:46 +00:00
|
|
|
SHAPE_SEGMENT slot = getPadHoleShape( aPad );
|
2020-07-31 08:54:53 +00:00
|
|
|
|
2022-11-12 14:23:46 +00:00
|
|
|
if( slot.GetSeg().A == slot.GetSeg().B ) // Circular hole
|
|
|
|
m_gal->DrawCircle( slot.GetSeg().A, slot.GetWidth() / 2.0 );
|
2020-07-31 08:54:53 +00:00
|
|
|
else
|
2022-11-12 14:23:46 +00:00
|
|
|
m_gal->DrawSegment( slot.GetSeg().A, slot.GetSeg().B, slot.GetWidth() );
|
2019-06-20 22:37:41 +00:00
|
|
|
}
|
2022-10-18 12:00:37 +00:00
|
|
|
else if( m_pcbSettings.IsPrinting() )
|
|
|
|
{
|
|
|
|
drawShape = aPad->FlashLayer( m_pcbSettings.GetPrintLayers() );
|
|
|
|
}
|
2022-12-24 17:04:34 +00:00
|
|
|
else if( aPad->FlashLayer( board->GetVisibleLayers() & board->GetEnabledLayers() ) )
|
2022-10-18 12:00:37 +00:00
|
|
|
{
|
|
|
|
drawShape = true;
|
|
|
|
}
|
|
|
|
else if( aPad->IsSelected() )
|
|
|
|
{
|
|
|
|
drawShape = true;
|
|
|
|
outline_mode = true;
|
|
|
|
}
|
|
|
|
|
2022-10-18 13:41:27 +00:00
|
|
|
if( outline_mode )
|
|
|
|
{
|
|
|
|
// Outline mode
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
}
|
|
|
|
|
2022-10-18 12:00:37 +00:00
|
|
|
if( drawShape )
|
2016-04-06 18:15:49 +00:00
|
|
|
{
|
2022-01-05 01:42:27 +00:00
|
|
|
VECTOR2I pad_size = aPad->GetSize();
|
|
|
|
VECTOR2I margin;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-06-20 22:37:41 +00:00
|
|
|
switch( aLayer )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2019-06-20 22:37:41 +00:00
|
|
|
case F_Mask:
|
|
|
|
case B_Mask:
|
2021-08-22 22:05:47 +00:00
|
|
|
margin.x = margin.y = aPad->GetSolderMaskExpansion();
|
2019-06-20 22:37:41 +00:00
|
|
|
break;
|
2013-09-03 11:51:53 +00:00
|
|
|
|
2019-06-20 22:37:41 +00:00
|
|
|
case F_Paste:
|
|
|
|
case B_Paste:
|
2020-08-23 17:11:47 +00:00
|
|
|
margin = aPad->GetSolderPasteMargin();
|
2019-06-20 22:37:41 +00:00
|
|
|
break;
|
2013-09-03 11:51:53 +00:00
|
|
|
|
2019-06-20 22:37:41 +00:00
|
|
|
default:
|
2020-06-22 19:35:09 +00:00
|
|
|
margin.x = margin.y = 0;
|
2019-06-20 22:37:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-06-22 19:35:09 +00:00
|
|
|
|
2020-12-27 21:10:11 +00:00
|
|
|
std::unique_ptr<PAD> dummyPad;
|
|
|
|
std::shared_ptr<SHAPE_COMPOUND> shapes;
|
|
|
|
|
2021-09-06 14:36:28 +00:00
|
|
|
// Drawing components of compound shapes in outline mode produces a mess.
|
2021-12-26 00:36:12 +00:00
|
|
|
bool simpleShapes = !outline_mode;
|
2021-07-26 23:36:44 +00:00
|
|
|
|
|
|
|
if( simpleShapes )
|
2020-06-22 19:35:09 +00:00
|
|
|
{
|
2021-07-26 23:36:44 +00:00
|
|
|
if( ( margin.x != margin.y && aPad->GetShape() != PAD_SHAPE::CUSTOM )
|
|
|
|
|| ( aPad->GetShape() == PAD_SHAPE::ROUNDRECT && ( margin.x < 0 || margin.y < 0 ) ) )
|
|
|
|
{
|
|
|
|
// Our algorithms below (polygon inflation in particular) can't handle differential
|
|
|
|
// inflation along separate axes. So for those cases we build a dummy pad instead,
|
|
|
|
// and inflate it.
|
2021-01-08 17:45:04 +00:00
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
// Margin is added to both sides. If the total margin is larger than the pad
|
|
|
|
// then don't display this layer
|
|
|
|
if( pad_size.x + 2 * margin.x <= 0 || pad_size.y + 2 * margin.y <= 0 )
|
|
|
|
return;
|
2021-01-08 17:45:04 +00:00
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
dummyPad.reset( static_cast<PAD*>( aPad->Duplicate() ) );
|
2023-01-16 17:30:03 +00:00
|
|
|
|
|
|
|
if( dummyPad->GetParentGroup() )
|
|
|
|
dummyPad->GetParentGroup()->RemoveItem( dummyPad.get() );
|
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
int initial_radius = dummyPad->GetRoundRectCornerRadius();
|
2021-06-21 11:44:30 +00:00
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
dummyPad->SetSize( pad_size + margin + margin );
|
2021-06-21 11:44:30 +00:00
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
if( dummyPad->GetShape() == PAD_SHAPE::ROUNDRECT )
|
|
|
|
{
|
|
|
|
// To keep the right margin around the corners, we need to modify the corner radius.
|
|
|
|
// We must have only one radius correction, so use the smallest absolute margin.
|
|
|
|
int radius_margin = std::max( margin.x, margin.y ); // radius_margin is < 0
|
|
|
|
dummyPad->SetRoundRectCornerRadius( std::max( initial_radius + radius_margin, 0 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( dummyPad->GetEffectiveShape() );
|
|
|
|
margin.x = margin.y = 0;
|
|
|
|
}
|
|
|
|
else
|
2021-06-21 11:44:30 +00:00
|
|
|
{
|
2021-07-26 23:36:44 +00:00
|
|
|
shapes = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
|
2021-06-21 11:44:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE::CUSTOM && ( margin.x || margin.y ) )
|
|
|
|
{
|
|
|
|
// We can't draw as shapes because we don't know which edges are internal and which
|
|
|
|
// are external (so we don't know when to apply the margin and when not to).
|
2020-10-14 14:55:06 +00:00
|
|
|
simpleShapes = false;
|
2021-07-26 23:36:44 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
2021-07-26 23:36:44 +00:00
|
|
|
for( const SHAPE* shape : shapes->Shapes() )
|
2020-10-14 14:55:06 +00:00
|
|
|
{
|
2021-07-26 23:36:44 +00:00
|
|
|
if( !simpleShapes )
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch( shape->Type() )
|
|
|
|
{
|
|
|
|
case SH_SEGMENT:
|
|
|
|
case SH_CIRCLE:
|
|
|
|
case SH_RECT:
|
|
|
|
case SH_SIMPLE:
|
|
|
|
// OK so far
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Not OK
|
|
|
|
simpleShapes = false;
|
|
|
|
break;
|
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
}
|
2020-06-22 19:35:09 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
|
|
|
if( simpleShapes )
|
2020-06-22 19:35:09 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const SHAPE* shape : shapes->Shapes() )
|
2020-10-14 14:55:06 +00:00
|
|
|
{
|
|
|
|
switch( shape->Type() )
|
|
|
|
{
|
|
|
|
case SH_SEGMENT:
|
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const SHAPE_SEGMENT* seg = (const SHAPE_SEGMENT*) shape;
|
2021-01-08 17:45:04 +00:00
|
|
|
int effectiveWidth = seg->GetWidth() + 2 * margin.x;
|
|
|
|
|
|
|
|
if( effectiveWidth > 0 )
|
|
|
|
m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, effectiveWidth );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-10-14 14:55:06 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
|
|
|
case SH_CIRCLE:
|
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const SHAPE_CIRCLE* circle = (const SHAPE_CIRCLE*) shape;
|
2021-01-08 17:45:04 +00:00
|
|
|
int effectiveRadius = circle->GetRadius() + margin.x;
|
|
|
|
|
|
|
|
if( effectiveRadius > 0 )
|
|
|
|
m_gal->DrawCircle( circle->GetCenter(), effectiveRadius );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-10-14 14:55:06 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
|
|
|
case SH_RECT:
|
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const SHAPE_RECT* r = (const SHAPE_RECT*) shape;
|
2021-05-03 11:11:21 +00:00
|
|
|
VECTOR2I pos = r->GetPosition();
|
|
|
|
VECTOR2I effectiveMargin = margin;
|
|
|
|
|
|
|
|
if( effectiveMargin.x < 0 )
|
2021-01-08 17:45:04 +00:00
|
|
|
{
|
2021-05-03 11:11:21 +00:00
|
|
|
// A negative margin just produces a smaller rect.
|
|
|
|
VECTOR2I effectiveSize = r->GetSize() + effectiveMargin;
|
|
|
|
|
2021-01-08 17:45:04 +00:00
|
|
|
if( effectiveSize.x > 0 && effectiveSize.y > 0 )
|
2021-05-03 11:11:21 +00:00
|
|
|
m_gal->DrawRectangle( pos - effectiveMargin, pos + effectiveSize );
|
2021-01-08 17:45:04 +00:00
|
|
|
}
|
2021-05-03 11:11:21 +00:00
|
|
|
else if( effectiveMargin.x > 0 )
|
2021-01-08 17:45:04 +00:00
|
|
|
{
|
2021-05-03 11:11:21 +00:00
|
|
|
// A positive margin produces a larger rect, but with rounded corners
|
2020-12-05 10:51:08 +00:00
|
|
|
m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
|
|
|
|
|
2021-05-03 11:11:21 +00:00
|
|
|
// Use segments to produce the margin with rounded corners
|
|
|
|
m_gal->DrawSegment( pos,
|
|
|
|
pos + VECTOR2I( r->GetWidth(), 0 ),
|
|
|
|
effectiveMargin.x * 2 );
|
|
|
|
m_gal->DrawSegment( pos + VECTOR2I( r->GetWidth(), 0 ),
|
|
|
|
pos + r->GetSize(),
|
|
|
|
effectiveMargin.x * 2 );
|
|
|
|
m_gal->DrawSegment( pos + r->GetSize(),
|
|
|
|
pos + VECTOR2I( 0, r->GetHeight() ),
|
|
|
|
effectiveMargin.x * 2 );
|
|
|
|
m_gal->DrawSegment( pos + VECTOR2I( 0, r->GetHeight() ),
|
|
|
|
pos,
|
|
|
|
effectiveMargin.x * 2 );
|
|
|
|
}
|
|
|
|
else
|
2020-10-14 14:55:06 +00:00
|
|
|
{
|
2021-05-03 11:11:21 +00:00
|
|
|
m_gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
|
2020-10-14 14:55:06 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-10-14 14:55:06 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
|
|
|
case SH_SIMPLE:
|
|
|
|
{
|
|
|
|
const SHAPE_SIMPLE* poly = static_cast<const SHAPE_SIMPLE*>( shape );
|
2021-06-21 16:52:57 +00:00
|
|
|
|
2022-10-09 19:23:38 +00:00
|
|
|
if( poly->PointCount() < 2 ) // Careful of empty pads
|
|
|
|
break;
|
|
|
|
|
2021-06-21 16:52:57 +00:00
|
|
|
if( margin.x < 0 ) // The poly shape must be deflated
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET outline;
|
|
|
|
outline.NewOutline();
|
|
|
|
|
|
|
|
for( int ii = 0; ii < poly->PointCount(); ++ii )
|
|
|
|
outline.Append( poly->CPoint( ii ) );
|
|
|
|
|
2023-10-05 07:34:24 +00:00
|
|
|
outline.Deflate( -margin.x, CORNER_STRATEGY::CHAMFER_ALL_CORNERS,
|
2023-05-29 15:22:06 +00:00
|
|
|
m_maxError );
|
2021-06-21 16:52:57 +00:00
|
|
|
|
|
|
|
m_gal->DrawPolygon( outline );
|
|
|
|
}
|
|
|
|
else
|
2021-06-23 22:53:08 +00:00
|
|
|
{
|
2021-06-21 16:52:57 +00:00
|
|
|
m_gal->DrawPolygon( poly->Vertices() );
|
2021-06-23 22:53:08 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
2021-01-08 17:45:04 +00:00
|
|
|
// Now add on a rounded margin (using segments) if the margin > 0
|
2020-10-14 14:55:06 +00:00
|
|
|
if( margin.x > 0 )
|
|
|
|
{
|
|
|
|
for( size_t ii = 0; ii < poly->GetSegmentCount(); ++ii )
|
|
|
|
{
|
|
|
|
SEG seg = poly->GetSegment( ii );
|
|
|
|
m_gal->DrawSegment( seg.A, seg.B, margin.x * 2 );
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-10-14 14:55:06 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-10-14 14:55:06 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
// Better not get here; we already pre-flighted the shapes...
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-06-22 19:35:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-14 14:55:06 +00:00
|
|
|
// This is expensive. Avoid if possible.
|
2020-06-22 19:35:09 +00:00
|
|
|
SHAPE_POLY_SET polySet;
|
2022-10-21 12:48:45 +00:00
|
|
|
aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), margin.x, m_maxError,
|
|
|
|
ERROR_INSIDE );
|
2020-06-22 19:35:09 +00:00
|
|
|
m_gal->DrawPolygon( polySet );
|
|
|
|
}
|
2013-09-03 11:51:53 +00:00
|
|
|
}
|
2017-01-24 16:58:11 +00:00
|
|
|
|
2022-02-12 16:32:55 +00:00
|
|
|
if( pcbconfig() && pcbconfig()->m_Display.m_PadClearance
|
2023-08-04 10:13:20 +00:00
|
|
|
&& ( aLayer == LAYER_PADS_SMD_FR || aLayer == LAYER_PADS_SMD_BK || aLayer == LAYER_PADS_TH )
|
2022-02-17 20:06:52 +00:00
|
|
|
&& !m_pcbSettings.m_isPrinting )
|
2017-01-24 16:58:11 +00:00
|
|
|
{
|
2020-12-27 10:20:48 +00:00
|
|
|
/* Showing the clearance area is not obvious.
|
|
|
|
* - A pad can be removed from some copper layers.
|
|
|
|
* - For non copper layers, what is the clearance area?
|
2020-12-27 21:10:11 +00:00
|
|
|
* So for copper layers, the clearance area is the shape if the pad is flashed on this
|
|
|
|
* layer and the hole clearance area for other copper layers.
|
2020-12-27 10:20:48 +00:00
|
|
|
* For other layers, use the pad shape, although one can use an other criteria,
|
2020-12-27 21:10:11 +00:00
|
|
|
* depending on the non copper layer.
|
2020-12-27 10:20:48 +00:00
|
|
|
*/
|
2021-07-10 09:13:02 +00:00
|
|
|
int activeLayer = m_pcbSettings.GetActiveLayer();
|
|
|
|
bool flashActiveLayer = true;
|
|
|
|
|
|
|
|
if( IsCopperLayer( activeLayer ) )
|
|
|
|
flashActiveLayer = aPad->FlashLayer( activeLayer );
|
2020-09-27 20:32:42 +00:00
|
|
|
|
2022-12-24 17:04:34 +00:00
|
|
|
if( !board->GetVisibleLayers().test( activeLayer ) )
|
|
|
|
flashActiveLayer = false;
|
|
|
|
|
2020-10-14 14:55:06 +00:00
|
|
|
if( flashActiveLayer || aPad->GetDrillSize().x )
|
2020-10-03 12:44:38 +00:00
|
|
|
{
|
2022-04-03 22:51:03 +00:00
|
|
|
if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
|
|
|
color = m_pcbSettings.GetLayerColor( LAYER_NON_PLATEDHOLES );
|
|
|
|
|
2020-10-03 12:44:38 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetStrokeColor( color );
|
2020-06-21 17:47:26 +00:00
|
|
|
|
2020-10-12 17:40:03 +00:00
|
|
|
int clearance = aPad->GetOwnClearance( m_pcbSettings.GetActiveLayer() );
|
2020-10-03 12:44:38 +00:00
|
|
|
|
2020-10-22 10:56:30 +00:00
|
|
|
if( flashActiveLayer && clearance > 0 )
|
2020-10-03 12:44:38 +00:00
|
|
|
{
|
|
|
|
auto shape = std::dynamic_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
|
|
|
|
|
|
|
|
if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_SEGMENT )
|
|
|
|
{
|
|
|
|
const SHAPE_SEGMENT* seg = (SHAPE_SEGMENT*) shape->Shapes()[0];
|
|
|
|
m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B,
|
|
|
|
seg->GetWidth() + 2 * clearance );
|
|
|
|
}
|
|
|
|
else if( shape && shape->Size() == 1 && shape->Shapes()[0]->Type() == SH_CIRCLE )
|
|
|
|
{
|
|
|
|
const SHAPE_CIRCLE* circle = (SHAPE_CIRCLE*) shape->Shapes()[0];
|
|
|
|
m_gal->DrawCircle( circle->GetCenter(), circle->GetRadius() + clearance );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET polySet;
|
2021-04-08 17:56:10 +00:00
|
|
|
|
|
|
|
// Use ERROR_INSIDE because it avoids Clipper and is therefore much faster.
|
2022-10-21 12:48:45 +00:00
|
|
|
aPad->TransformShapeToPolygon( polySet, ToLAYER_ID( aLayer ), clearance,
|
|
|
|
m_maxError, ERROR_INSIDE );
|
2022-10-09 19:23:38 +00:00
|
|
|
|
|
|
|
if( polySet.Outline( 0 ).PointCount() > 2 ) // Careful of empty pads
|
|
|
|
m_gal->DrawPolygon( polySet );
|
2020-10-03 12:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-22 10:56:30 +00:00
|
|
|
else if( aPad->GetEffectiveHoleShape() && clearance > 0 )
|
2020-10-03 12:44:38 +00:00
|
|
|
{
|
2022-07-22 22:05:25 +00:00
|
|
|
std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
|
|
|
|
m_gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B,
|
|
|
|
slot->GetWidth() + 2 * clearance );
|
2020-10-03 12:44:38 +00:00
|
|
|
}
|
2020-06-21 17:47:26 +00:00
|
|
|
}
|
2017-01-24 16:58:11 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
|
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
|
|
|
{
|
2023-11-25 13:05:45 +00:00
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aShape, aLayer );
|
|
|
|
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayGraphicsFill;
|
|
|
|
int thickness = getLineThickness( aShape->GetWidth() );
|
|
|
|
LINE_STYLE lineStyle = aShape->GetStroke().GetLineStyle();
|
2020-11-14 01:16:02 +00:00
|
|
|
|
2024-03-03 15:59:00 +00:00
|
|
|
if( IsNetnameLayer( aLayer ) )
|
2023-07-30 19:39:07 +00:00
|
|
|
{
|
2024-03-03 15:59:00 +00:00
|
|
|
// Net names are shown only in board editor:
|
|
|
|
if( m_frameType != FRAME_T::FRAME_PCB_EDITOR )
|
|
|
|
return;
|
|
|
|
|
2023-07-30 19:39:07 +00:00
|
|
|
if( !pcbconfig() || pcbconfig()->m_Display.m_NetNames < 2 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aShape->GetNetCode() <= NETINFO_LIST::UNCONNECTED )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString netname = aShape->GetUnescapedShortNetname();
|
|
|
|
|
|
|
|
if( netname.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aShape->GetShape() == SHAPE_T::SEGMENT )
|
|
|
|
{
|
|
|
|
SHAPE_SEGMENT seg( { aShape->GetStart(), aShape->GetEnd() }, aShape->GetWidth() );
|
|
|
|
renderNetNameForSegment( seg, color, netname );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Maybe use some of the pad code?
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
|
|
|
{
|
|
|
|
color = m_pcbSettings.GetColor( aShape, aLayer );
|
2022-08-23 22:25:55 +00:00
|
|
|
thickness = thickness + m_lockedShadowMargin;
|
2022-03-07 17:03:06 +00:00
|
|
|
}
|
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
}
|
2014-07-09 13:10:32 +00:00
|
|
|
|
2017-03-10 12:47:39 +00:00
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetStrokeColor( color );
|
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
|
|
|
|
2023-12-10 14:36:33 +00:00
|
|
|
// Note: on LAYER_LOCKED_ITEM_SHADOW always draw shadow shapes as continuous lines
|
|
|
|
// otherwise the look is very strange and ugly
|
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE || aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
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-08-25 23:14:36 +00:00
|
|
|
switch( aShape->GetShape() )
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::SEGMENT:
|
2023-09-13 10:27:04 +00:00
|
|
|
if( aShape->IsProxyItem() )
|
|
|
|
{
|
2023-09-13 17:27:00 +00:00
|
|
|
std::vector<VECTOR2I> pts;
|
|
|
|
VECTOR2I offset = ( aShape->GetEnd() - aShape->GetStart() ).Perpendicular();
|
|
|
|
offset = offset.Resize( thickness / 2 );
|
|
|
|
|
|
|
|
pts.push_back( aShape->GetStart() + offset );
|
|
|
|
pts.push_back( aShape->GetStart() - offset );
|
|
|
|
pts.push_back( aShape->GetEnd() - offset );
|
|
|
|
pts.push_back( aShape->GetEnd() + offset );
|
|
|
|
|
2023-09-13 10:27:04 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
2023-09-13 17:27:00 +00:00
|
|
|
m_gal->DrawLine( pts[0], pts[1] );
|
|
|
|
m_gal->DrawLine( pts[1], pts[2] );
|
|
|
|
m_gal->DrawLine( pts[2], pts[3] );
|
|
|
|
m_gal->DrawLine( pts[3], pts[0] );
|
|
|
|
m_gal->DrawLine( ( pts[0] + pts[1] ) / 2, ( pts[1] + pts[2] ) / 2 );
|
|
|
|
m_gal->DrawLine( ( pts[1] + pts[2] ) / 2, ( pts[2] + pts[3] ) / 2 );
|
|
|
|
m_gal->DrawLine( ( pts[2] + pts[3] ) / 2, ( pts[3] + pts[0] ) / 2 );
|
|
|
|
m_gal->DrawLine( ( pts[3] + pts[0] ) / 2, ( pts[0] + pts[1] ) / 2 );
|
2023-09-13 10:27:04 +00:00
|
|
|
}
|
|
|
|
else if( outline_mode )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
m_gal->DrawSegment( aShape->GetStart(), aShape->GetEnd(), thickness );
|
|
|
|
}
|
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-08-25 23:14:36 +00:00
|
|
|
break;
|
2020-06-15 19:50:20 +00:00
|
|
|
|
2023-07-24 16:07:56 +00:00
|
|
|
case SHAPE_T::RECTANGLE:
|
2020-06-19 20:46:43 +00:00
|
|
|
{
|
2022-01-01 06:04:08 +00:00
|
|
|
std::vector<VECTOR2I> pts = aShape->GetRectCorners();
|
2020-11-14 01:16:02 +00:00
|
|
|
|
2023-09-13 10:27:04 +00:00
|
|
|
if( aShape->IsProxyItem() )
|
2022-09-14 10:34:10 +00:00
|
|
|
{
|
2023-09-04 18:44:39 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->DrawLine( pts[0], pts[1] );
|
|
|
|
m_gal->DrawLine( pts[1], pts[2] );
|
|
|
|
m_gal->DrawLine( pts[2], pts[3] );
|
|
|
|
m_gal->DrawLine( pts[3], pts[0] );
|
|
|
|
m_gal->DrawLine( pts[0], pts[2] );
|
|
|
|
m_gal->DrawLine( pts[1], pts[3] );
|
2022-09-14 10:34:10 +00:00
|
|
|
}
|
|
|
|
else if( outline_mode )
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
|
|
|
m_gal->DrawSegment( pts[0], pts[1], thickness );
|
|
|
|
m_gal->DrawSegment( pts[1], pts[2], thickness );
|
|
|
|
m_gal->DrawSegment( pts[2], pts[3], thickness );
|
|
|
|
m_gal->DrawSegment( pts[3], pts[0], thickness );
|
|
|
|
}
|
2021-08-25 23:14:36 +00:00
|
|
|
else
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2020-06-19 20:46:43 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
if( thickness > 0 )
|
|
|
|
{
|
|
|
|
m_gal->DrawSegment( pts[0], pts[1], thickness );
|
|
|
|
m_gal->DrawSegment( pts[1], pts[2], thickness );
|
|
|
|
m_gal->DrawSegment( pts[2], pts[3], thickness );
|
|
|
|
m_gal->DrawSegment( pts[3], pts[0], thickness );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
if( aShape->IsFilled() )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET poly;
|
|
|
|
poly.NewOutline();
|
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
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
for( const VECTOR2I& pt : pts )
|
2021-08-25 23:14:36 +00:00
|
|
|
poly.Append( pt );
|
2021-10-14 23:39:31 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
m_gal->DrawPolygon( poly );
|
|
|
|
}
|
|
|
|
}
|
2020-11-14 01:16:02 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
break;
|
2020-11-14 01:16:02 +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-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::ARC:
|
2017-03-10 12:47:39 +00:00
|
|
|
{
|
2022-01-16 01:06:25 +00:00
|
|
|
EDA_ANGLE startAngle;
|
|
|
|
EDA_ANGLE endAngle;
|
2021-08-25 23:14:36 +00:00
|
|
|
aShape->CalcArcAngles( startAngle, endAngle );
|
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
2022-01-16 16:15:07 +00:00
|
|
|
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
|
2023-08-22 13:06:53 +00:00
|
|
|
endAngle - startAngle, thickness, m_maxError );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2020-11-14 01:16:02 +00:00
|
|
|
|
2022-01-16 16:15:07 +00:00
|
|
|
m_gal->DrawArcSegment( aShape->GetCenter(), aShape->GetRadius(), startAngle,
|
2023-08-22 13:06:53 +00:00
|
|
|
endAngle - startAngle, thickness, m_maxError );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-03-10 12:47: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
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::CIRCLE:
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() - thickness / 2 );
|
|
|
|
m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() + thickness / 2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetIsFill( aShape->IsFilled() );
|
|
|
|
m_gal->SetIsStroke( thickness > 0 );
|
|
|
|
m_gal->SetLineWidth( thickness );
|
2013-07-31 09:36:46 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
m_gal->DrawCircle( aShape->GetStart(), aShape->GetRadius() );
|
|
|
|
}
|
2017-07-28 08:34:45 +00:00
|
|
|
break;
|
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::POLY:
|
2020-11-14 13:20:13 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
SHAPE_POLY_SET& shape = const_cast<PCB_SHAPE*>( aShape )->GetPolyShape();
|
2020-11-14 13:20:13 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
if( shape.OutlineCount() == 0 )
|
|
|
|
break;
|
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
2022-11-09 00:03:59 +00:00
|
|
|
for( int ii = 0; ii < shape.OutlineCount(); ++ii )
|
|
|
|
m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
|
2020-11-14 01:16:02 +00:00
|
|
|
}
|
2021-08-25 23:14:36 +00:00
|
|
|
else
|
2020-11-14 01:16:02 +00:00
|
|
|
{
|
2021-08-25 23:14:36 +00:00
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
|
|
|
|
if( thickness > 0 )
|
|
|
|
{
|
2022-11-09 00:03:59 +00:00
|
|
|
for( int ii = 0; ii < shape.OutlineCount(); ++ii )
|
|
|
|
m_gal->DrawSegmentChain( shape.Outline( ii ), thickness );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( aShape->IsFilled() )
|
|
|
|
{
|
|
|
|
// On Opengl, a not convex filled polygon is usually drawn by using triangles
|
|
|
|
// as primitives. CacheTriangulation() can create basic triangle primitives to
|
|
|
|
// draw the polygon solid shape on Opengl. GLU tessellation is much slower,
|
|
|
|
// so currently we are using our tessellation.
|
|
|
|
if( m_gal->IsOpenGlEngine() && !shape.IsTriangulationUpToDate() )
|
2022-11-28 22:54:53 +00:00
|
|
|
shape.CacheTriangulation( true, true );
|
2021-08-25 23:14:36 +00:00
|
|
|
|
|
|
|
m_gal->DrawPolygon( shape );
|
|
|
|
}
|
2020-11-14 01:16:02 +00:00
|
|
|
}
|
2013-07-31 09:36:46 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
break;
|
|
|
|
}
|
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-08-25 23:14:36 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
std::vector<VECTOR2D> output;
|
|
|
|
std::vector<VECTOR2D> pointCtrl;
|
2021-11-04 12:56:14 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
pointCtrl.push_back( aShape->GetStart() );
|
|
|
|
pointCtrl.push_back( aShape->GetBezierC1() );
|
|
|
|
pointCtrl.push_back( aShape->GetBezierC2() );
|
|
|
|
pointCtrl.push_back( aShape->GetEnd() );
|
2021-11-04 12:56:14 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
BEZIER_POLY converter( pointCtrl );
|
|
|
|
converter.GetPoly( output, thickness );
|
2021-11-04 12:56:14 +00:00
|
|
|
|
2022-09-14 16:07:47 +00:00
|
|
|
m_gal->DrawSegmentChain( output, thickness );
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-14 01:16:02 +00:00
|
|
|
m_gal->SetIsFill( aShape->IsFilled() );
|
|
|
|
m_gal->SetIsStroke( thickness > 0 );
|
|
|
|
m_gal->SetLineWidth( thickness );
|
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
// Use thickness as filter value to convert the curve to polyline when the curve
|
|
|
|
// is not supported
|
|
|
|
m_gal->DrawCurve( VECTOR2D( aShape->GetStart() ),
|
|
|
|
VECTOR2D( aShape->GetBezierC1() ),
|
|
|
|
VECTOR2D( aShape->GetBezierC2() ),
|
|
|
|
VECTOR2D( aShape->GetEnd() ), thickness );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2024-01-20 23:35:29 +00:00
|
|
|
|
|
|
|
case SHAPE_T::UNDEFINED:
|
|
|
|
break;
|
2021-08-25 23:14:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
if( !outline_mode )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2020-11-14 01:16:02 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( 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-08-25 23:14:36 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
|
2022-01-01 18:08:03 +00:00
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
2021-08-25 23:14:36 +00:00
|
|
|
{
|
|
|
|
m_gal->DrawSegment( a, b, thickness );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-04 23:00:00 +00:00
|
|
|
void PCB_PAINTER::strokeText( const wxString& aText, const VECTOR2I& aPosition,
|
2023-08-06 19:20:53 +00:00
|
|
|
const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
|
2021-12-31 14:07:24 +00:00
|
|
|
{
|
|
|
|
KIFONT::FONT* font = aAttrs.m_Font;
|
|
|
|
|
|
|
|
if( !font )
|
|
|
|
font = KIFONT::FONT::GetFont( wxEmptyString, aAttrs.m_Bold, aAttrs.m_Italic );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( font->IsOutline() );
|
|
|
|
m_gal->SetIsStroke( font->IsStroke() );
|
|
|
|
|
2023-05-17 20:30:31 +00:00
|
|
|
VECTOR2I pos( aPosition );
|
2023-09-18 13:47:38 +00:00
|
|
|
VECTOR2I fudge( KiROUND( 0.16 * aAttrs.m_StrokeWidth ), 0 );
|
|
|
|
|
2023-05-17 20:30:31 +00:00
|
|
|
RotatePoint( fudge, aAttrs.m_Angle );
|
|
|
|
|
|
|
|
if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && !aAttrs.m_Mirrored )
|
|
|
|
|| ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && aAttrs.m_Mirrored ) )
|
|
|
|
{
|
|
|
|
pos -= fudge;
|
|
|
|
}
|
|
|
|
else if( ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && !aAttrs.m_Mirrored )
|
|
|
|
|| ( aAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && aAttrs.m_Mirrored ) )
|
|
|
|
{
|
|
|
|
pos += fudge;
|
|
|
|
}
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
font->Draw( m_gal, aText, pos, aAttrs, aFontMetrics );
|
2021-12-31 14:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-23 17:23:24 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_REFERENCE_IMAGE* aBitmap, int aLayer )
|
2022-02-08 19:29:54 +00:00
|
|
|
{
|
|
|
|
m_gal->Save();
|
|
|
|
m_gal->Translate( aBitmap->GetPosition() );
|
|
|
|
|
|
|
|
// When the image scale factor is not 1.0, we need to modify the actual as the image scale
|
|
|
|
// factor is similar to a local zoom
|
|
|
|
double img_scale = aBitmap->GetImageScale();
|
|
|
|
|
|
|
|
if( img_scale != 1.0 )
|
|
|
|
m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
|
|
|
|
|
|
|
|
if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
|
|
|
|
{
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aBitmap, LAYER_ANCHOR );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
|
|
|
|
// Draws a bounding box.
|
|
|
|
VECTOR2D bm_size( aBitmap->GetSize() );
|
|
|
|
// bm_size is the actual image size in UI.
|
|
|
|
// but m_gal scale was previously set to img_scale
|
|
|
|
// so recalculate size relative to this image size.
|
|
|
|
bm_size.x /= img_scale;
|
|
|
|
bm_size.y /= img_scale;
|
|
|
|
VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
|
|
|
|
VECTOR2D end = origin + bm_size;
|
|
|
|
|
|
|
|
m_gal->DrawRectangle( origin, end );
|
2022-06-27 18:07:52 +00:00
|
|
|
|
2023-10-23 17:23:24 +00:00
|
|
|
// Hard code reference images as opaque when selected. Otherwise cached layers will
|
|
|
|
// not be rendered under the selected image because cached layers are rendered after
|
|
|
|
// non-cached layers (e.g. bitmaps), which will have a closer Z order.
|
2022-06-27 18:07:52 +00:00
|
|
|
m_gal->DrawBitmap( *aBitmap->GetImage(), 1.0 );
|
2022-02-08 19:29:54 +00:00
|
|
|
}
|
2022-06-27 18:07:52 +00:00
|
|
|
else
|
2022-07-20 18:46:30 +00:00
|
|
|
m_gal->DrawBitmap( *aBitmap->GetImage(),
|
|
|
|
m_pcbSettings.GetColor( aBitmap, aBitmap->GetLayer() ).a );
|
2022-06-27 18:07:52 +00:00
|
|
|
|
2022-02-08 19:29:54 +00:00
|
|
|
|
|
|
|
m_gal->Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
|
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
|
|
|
{
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString resolvedText( aText->GetShownText( true ) );
|
2020-04-14 12:25:00 +00:00
|
|
|
|
2024-02-08 15:27:58 +00:00
|
|
|
if( resolvedText.Length() == 0
|
|
|
|
|| !( aText->GetAttributes().m_Visible || aLayer == LAYER_HIDDEN_TEXT ) )
|
2013-10-02 09:39:08 +00:00
|
|
|
return;
|
2013-07-09 08:00:23 +00:00
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
|
|
|
|
{
|
|
|
|
const COLOR4D color = m_pcbSettings.GetColor( aText, aLayer );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
2022-08-23 22:25:55 +00:00
|
|
|
m_gal->SetIsStroke( true );
|
2022-03-07 17:03:06 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2023-03-28 20:01:08 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2022-08-23 22:25:55 +00:00
|
|
|
m_gal->SetLineWidth( m_lockedShadowMargin );
|
2022-03-07 17:03:06 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET poly;
|
2022-10-21 12:48:45 +00:00
|
|
|
aText->TransformShapeToPolygon( poly, aText->GetLayer(), 0, m_maxError, ERROR_OUTSIDE );
|
2022-03-07 17:03:06 +00:00
|
|
|
m_gal->DrawPolygon( poly );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-08 13:16:39 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
2023-08-04 09:50:19 +00:00
|
|
|
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
|
2022-07-24 22:40:47 +00:00
|
|
|
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
|
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
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
KIFONT::FONT* font = aText->GetFont();
|
|
|
|
|
|
|
|
if( !font )
|
|
|
|
{
|
|
|
|
font = KIFONT::FONT::GetFont( m_pcbSettings.GetDefaultFont(), aText->IsBold(),
|
|
|
|
aText->IsItalic() );
|
|
|
|
}
|
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
2023-03-30 11:49:23 +00:00
|
|
|
attrs.m_Angle = aText->GetDrawRotation();
|
2021-12-31 14:07:24 +00:00
|
|
|
|
2022-03-08 13:16:39 +00:00
|
|
|
if( aText->IsKnockout() )
|
|
|
|
{
|
|
|
|
SHAPE_POLY_SET finalPoly;
|
2023-05-28 16:20:11 +00:00
|
|
|
aText->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE );
|
2022-03-08 13:16:39 +00:00
|
|
|
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->DrawPolygon( finalPoly );
|
2022-01-04 23:00:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-08 13:16:39 +00:00
|
|
|
if( outline_mode )
|
|
|
|
attrs.m_StrokeWidth = m_pcbSettings.m_outlineWidth;
|
|
|
|
else
|
|
|
|
attrs.m_StrokeWidth = getLineThickness( aText->GetEffectiveTextPenWidth() );
|
|
|
|
|
2022-10-25 11:08:32 +00:00
|
|
|
if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
2022-09-15 23:45:43 +00:00
|
|
|
{
|
|
|
|
attrs.m_Mirrored = !attrs.m_Mirrored;
|
|
|
|
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
|
|
|
if( font->IsOutline() )
|
|
|
|
cache = aText->GetRenderCache( font, resolvedText );
|
2022-03-08 13:16:39 +00:00
|
|
|
|
|
|
|
if( cache )
|
2023-04-17 14:15:29 +00:00
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( attrs.m_StrokeWidth );
|
2022-09-14 16:07:47 +00:00
|
|
|
m_gal->DrawGlyphs( *cache );
|
2023-04-17 14:15:29 +00:00
|
|
|
}
|
2022-03-08 13:16:39 +00:00
|
|
|
else
|
2023-04-17 14:15:29 +00:00
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( resolvedText, aText->GetTextPos(), attrs, aText->GetFontMetrics() );
|
2023-04-17 14:15:29 +00:00
|
|
|
}
|
2022-01-04 23:00:00 +00:00
|
|
|
}
|
2023-04-18 07:48:46 +00:00
|
|
|
|
|
|
|
// Draw the umbilical line for texts in footprints
|
|
|
|
FOOTPRINT* fp_parent = aText->GetParentFootprint();
|
|
|
|
|
|
|
|
if( fp_parent && aText->IsSelected() )
|
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( nullptr, LAYER_ANCHOR ) );
|
|
|
|
m_gal->DrawLine( aText->GetTextPos(), fp_parent->GetPosition() );
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
|
|
|
|
{
|
2024-01-15 17:29:55 +00:00
|
|
|
if( aTextBox->Type() == PCB_TABLECELL_T )
|
|
|
|
{
|
|
|
|
const PCB_TABLECELL* cell = static_cast<const PCB_TABLECELL*>( aTextBox );
|
|
|
|
|
|
|
|
if( cell->GetColSpan() == 0 || cell->GetRowSpan() == 0 )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aTextBox, aLayer );
|
|
|
|
int thickness = getLineThickness( aTextBox->GetWidth() );
|
|
|
|
LINE_STYLE lineStyle = aTextBox->GetStroke().GetLineStyle();
|
|
|
|
wxString resolvedText( aTextBox->GetShownText( true ) );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
KIFONT::FONT* font = aTextBox->GetFont();
|
|
|
|
|
|
|
|
if( !font )
|
|
|
|
{
|
|
|
|
font = KIFONT::FONT::GetFont( m_pcbSettings.GetDefaultFont(), aTextBox->IsBold(),
|
|
|
|
aTextBox->IsItalic() );
|
|
|
|
}
|
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) // happens only if locked
|
|
|
|
{
|
|
|
|
const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetFillColor( sh_color );
|
|
|
|
m_gal->SetStrokeColor( sh_color );
|
|
|
|
|
|
|
|
// Draw the box with a larger thickness than box thickness to show
|
|
|
|
// the shadow mask
|
|
|
|
std::vector<VECTOR2I> pts = aTextBox->GetCorners();
|
2022-09-16 11:33:56 +00:00
|
|
|
int line_thickness = std::max( thickness*3, pcbIUScale.mmToIU( 0.2 ) );
|
2022-03-07 17:03:06 +00:00
|
|
|
|
2023-08-20 15:29:09 +00:00
|
|
|
std::deque<VECTOR2D> dpts;
|
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
for( size_t ii = 0; ii < pts.size(); ++ii )
|
2023-08-20 15:29:09 +00:00
|
|
|
dpts.push_back( VECTOR2D( pts[ii] ) );
|
|
|
|
|
|
|
|
dpts.push_back( VECTOR2D( pts[0] ) );
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( line_thickness );
|
|
|
|
m_gal->DrawPolygon( dpts );
|
2022-03-07 17:03:06 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
if( aTextBox->Type() == PCB_TABLECELL_T )
|
|
|
|
{
|
|
|
|
// Selection for tables is done with a background wash, so pass in nullptr to GetColor()
|
|
|
|
// so we just get the "normal" (un-selected/un-brightened) color for the borders.
|
|
|
|
color = m_pcbSettings.GetColor( nullptr, aLayer );
|
|
|
|
}
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
|
2024-02-03 13:43:41 +00:00
|
|
|
if( aTextBox->Type() != PCB_TABLECELL_T && aTextBox->IsBorderEnabled() )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-11-25 13:05:45 +00:00
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-08-31 11:52:19 +00:00
|
|
|
if( thickness > 0 )
|
|
|
|
{
|
|
|
|
std::vector<VECTOR2I> pts = aTextBox->GetCorners();
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-08-31 11:52:19 +00:00
|
|
|
for( size_t ii = 0; ii < pts.size(); ++ii )
|
|
|
|
m_gal->DrawSegment( pts[ii], pts[( ii + 1 ) % pts.size()], thickness );
|
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
}
|
2023-08-31 11:52:19 +00:00
|
|
|
else
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
2023-08-31 11:52:19 +00:00
|
|
|
std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
|
2022-01-30 10:52:52 +00:00
|
|
|
|
2023-08-31 11:52:19 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings,
|
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
m_gal->DrawSegment( a, b, thickness );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( resolvedText.Length() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
|
|
|
|
attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() );
|
|
|
|
|
2022-10-25 11:08:32 +00:00
|
|
|
if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
2022-09-15 23:45:43 +00:00
|
|
|
{
|
|
|
|
attrs.m_Mirrored = !attrs.m_Mirrored;
|
|
|
|
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
|
|
|
|
}
|
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
|
|
|
|
{
|
2023-08-20 15:29:09 +00:00
|
|
|
// For now, the textbox is a filled shape.
|
|
|
|
// so the text drawn on LAYER_LOCKED_ITEM_SHADOW with a thick width is disabled
|
|
|
|
// If enabled, the thick text position must be offsetted to be exactly on the
|
|
|
|
// initial text, which is not easy, depending on its rotation and justification.
|
2024-01-15 17:29:55 +00:00
|
|
|
#if 0
|
2022-03-07 17:03:06 +00:00
|
|
|
const COLOR4D sh_color = m_pcbSettings.GetColor( aTextBox, aLayer );
|
|
|
|
m_gal->SetFillColor( sh_color );
|
|
|
|
m_gal->SetStrokeColor( sh_color );
|
2022-08-23 22:25:55 +00:00
|
|
|
attrs.m_StrokeWidth += m_lockedShadowMargin;
|
2024-01-15 17:29:55 +00:00
|
|
|
#else
|
2023-08-20 15:29:09 +00:00
|
|
|
return;
|
2024-01-15 17:29:55 +00:00
|
|
|
#endif
|
2022-03-07 17:03:06 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
|
|
|
if( font->IsOutline() )
|
|
|
|
cache = aTextBox->GetRenderCache( font, resolvedText );
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
if( cache )
|
2023-04-17 14:15:29 +00:00
|
|
|
{
|
|
|
|
m_gal->SetLineWidth( attrs.m_StrokeWidth );
|
2022-09-14 16:07:47 +00:00
|
|
|
m_gal->DrawGlyphs( *cache );
|
2023-04-17 14:15:29 +00:00
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
else
|
2023-04-17 14:15:29 +00:00
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( resolvedText, aTextBox->GetDrawPos(), attrs, aTextBox->GetFontMetrics() );
|
2023-04-17 14:15:29 +00:00
|
|
|
}
|
2022-01-30 10:52:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-15 17:29:55 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_TABLE* aTable, int aLayer )
|
|
|
|
{
|
|
|
|
for( PCB_TABLECELL* cell : aTable->GetCells() )
|
|
|
|
draw( static_cast<PCB_TEXTBOX*>( cell ), aLayer );
|
|
|
|
|
|
|
|
VECTOR2I pos = aTable->GetPosition();
|
|
|
|
VECTOR2I end = aTable->GetEnd();
|
|
|
|
|
|
|
|
// Selection for tables is done with a background wash, so pass in nullptr to GetColor()
|
|
|
|
// so we just get the "normal" (un-selected/un-brightened) color for the borders.
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( nullptr, aLayer );
|
|
|
|
int lineWidth;
|
|
|
|
LINE_STYLE lineStyle;
|
|
|
|
|
|
|
|
auto setupStroke =
|
|
|
|
[&]( const STROKE_PARAMS& stroke )
|
|
|
|
{
|
|
|
|
lineWidth = getLineThickness( stroke.GetWidth() );
|
|
|
|
lineStyle = stroke.GetLineStyle();
|
|
|
|
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetLineWidth( lineWidth );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeShape =
|
|
|
|
[&]( const SHAPE& shape )
|
|
|
|
{
|
|
|
|
STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, &m_pcbSettings,
|
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
// DrawLine has problem with 0 length lines so enforce minimum
|
|
|
|
if( a == b )
|
|
|
|
m_gal->DrawLine( a+1, b );
|
|
|
|
else
|
|
|
|
m_gal->DrawLine( a, b );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeLine =
|
|
|
|
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
|
|
|
|
{
|
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
|
|
|
{
|
|
|
|
m_gal->DrawLine( ptA, ptB );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SHAPE_SEGMENT seg( ptA, ptB );
|
|
|
|
strokeShape( seg );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto strokeRect =
|
|
|
|
[&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
|
|
|
|
{
|
|
|
|
if( lineStyle <= LINE_STYLE::FIRST_TYPE )
|
|
|
|
{
|
|
|
|
m_gal->DrawRectangle( ptA, ptB );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SHAPE_RECT rect( BOX2I( ptA, ptB - ptA ) );
|
|
|
|
strokeShape( rect );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
|
|
|
|
{
|
|
|
|
setupStroke( aTable->GetSeparatorsStroke() );
|
|
|
|
|
|
|
|
if( aTable->StrokeColumns() )
|
|
|
|
{
|
|
|
|
for( int col = 0; col < aTable->GetColCount() - 1; ++col )
|
|
|
|
{
|
|
|
|
for( int row = 0; row < aTable->GetRowCount(); ++row )
|
|
|
|
{
|
|
|
|
PCB_TABLECELL* cell = aTable->GetCell( row, col );
|
2024-03-11 22:57:02 +00:00
|
|
|
VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
|
2024-01-15 17:29:55 +00:00
|
|
|
|
|
|
|
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
2024-03-11 22:57:02 +00:00
|
|
|
strokeLine( topRight, cell->GetEnd() );
|
2024-01-15 17:29:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->StrokeRows() )
|
|
|
|
{
|
|
|
|
for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
|
|
|
|
{
|
|
|
|
for( int col = 0; col < aTable->GetColCount(); ++col )
|
|
|
|
{
|
2024-02-03 13:43:41 +00:00
|
|
|
PCB_TABLECELL* cell = aTable->GetCell( row, col );
|
2024-03-11 22:57:02 +00:00
|
|
|
VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
|
2024-01-15 17:29:55 +00:00
|
|
|
|
|
|
|
if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
|
2024-03-11 22:57:02 +00:00
|
|
|
strokeLine( botLeft, cell->GetEnd() );
|
2024-01-15 17:29:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->GetBorderStroke().GetWidth() >= 0 )
|
|
|
|
{
|
|
|
|
setupStroke( aTable->GetBorderStroke() );
|
|
|
|
|
|
|
|
if( aTable->StrokeHeader() )
|
|
|
|
{
|
|
|
|
PCB_TABLECELL* cell = aTable->GetCell( 0, 0 );
|
|
|
|
strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTable->StrokeExternal() )
|
|
|
|
strokeRect( pos, end );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Highlight selected tablecells with a background wash.
|
|
|
|
for( PCB_TABLECELL* cell : aTable->GetCells() )
|
|
|
|
{
|
2024-03-09 19:19:47 +00:00
|
|
|
if( aTable->IsSelected() || cell->IsSelected() )
|
2024-01-15 17:29:55 +00:00
|
|
|
{
|
|
|
|
std::vector<VECTOR2I> corners = cell->GetCorners();
|
|
|
|
std::deque<VECTOR2D> pts;
|
|
|
|
|
|
|
|
pts.insert( pts.end(), corners.begin(), corners.end() );
|
|
|
|
|
|
|
|
m_gal->SetFillColor( color.WithAlpha( 0.5 ) );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->DrawPolygon( pts );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void PCB_PAINTER::draw( const FOOTPRINT* aFootprint, int aLayer )
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
if( aLayer == LAYER_ANCHOR )
|
2014-08-04 08:42:20 +00:00
|
|
|
{
|
2020-11-13 02:09:34 +00:00
|
|
|
const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
|
2020-09-20 09:06:31 +00:00
|
|
|
|
|
|
|
// Keep the size and width constant, not related to the scale because the anchor
|
|
|
|
// is just a marker on screen
|
|
|
|
double anchorSize = 5.0 / m_gal->GetWorldScale(); // 5 pixels size
|
2020-09-21 15:03:08 +00:00
|
|
|
double anchorThickness = 1.0 / m_gal->GetWorldScale(); // 1 pixels width
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2014-08-04 08:42:20 +00:00
|
|
|
// Draw anchor
|
2020-09-20 09:06:31 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2014-08-04 08:42:20 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2020-09-20 09:06:31 +00:00
|
|
|
m_gal->SetLineWidth( anchorThickness );
|
2014-07-09 13:02:56 +00:00
|
|
|
|
2020-11-13 02:09:34 +00:00
|
|
|
VECTOR2D center = aFootprint->GetPosition();
|
2014-08-04 08:42:20 +00:00
|
|
|
m_gal->DrawLine( center - VECTOR2D( anchorSize, 0 ), center + VECTOR2D( anchorSize, 0 ) );
|
|
|
|
m_gal->DrawLine( center - VECTOR2D( 0, anchorSize ), center + VECTOR2D( 0, anchorSize ) );
|
|
|
|
}
|
2022-03-06 19:11:03 +00:00
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
if( aLayer == LAYER_LOCKED_ITEM_SHADOW && m_frameType == FRAME_PCB_EDITOR ) // happens only if locked
|
2022-03-06 19:11:03 +00:00
|
|
|
{
|
|
|
|
const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
|
2022-08-03 09:10:23 +00:00
|
|
|
#if 0 // GetBoundingHull() can be very slow, especially for logos imported from graphics
|
2022-03-14 15:52:12 +00:00
|
|
|
const SHAPE_POLY_SET& poly = aFootprint->GetBoundingHull();
|
2022-03-06 19:11:03 +00:00
|
|
|
m_gal->DrawPolygon( poly );
|
2022-08-03 09:10:23 +00:00
|
|
|
#else
|
2022-08-31 16:17:14 +00:00
|
|
|
BOX2I bbox = aFootprint->GetBoundingBox( false, false );
|
2022-08-23 22:25:55 +00:00
|
|
|
VECTOR2I topLeft = bbox.GetPosition();
|
|
|
|
VECTOR2I botRight = bbox.GetPosition() + bbox.GetSize();
|
|
|
|
|
|
|
|
m_gal->DrawRectangle( topLeft, botRight );
|
|
|
|
|
|
|
|
// Use segments to produce a margin with rounded corners
|
|
|
|
m_gal->DrawSegment( topLeft, VECTOR2I( botRight.x, topLeft.y ), m_lockedShadowMargin );
|
|
|
|
m_gal->DrawSegment( VECTOR2I( botRight.x, topLeft.y ), botRight, m_lockedShadowMargin );
|
|
|
|
m_gal->DrawSegment( botRight, VECTOR2I( topLeft.x, botRight.y ), m_lockedShadowMargin );
|
|
|
|
m_gal->DrawSegment( VECTOR2I( topLeft.x, botRight.y ), topLeft, m_lockedShadowMargin );
|
2022-08-03 09:10:23 +00:00
|
|
|
#endif
|
2022-03-06 19:11:03 +00:00
|
|
|
}
|
2022-05-20 09:08:33 +00:00
|
|
|
|
2022-10-07 21:21:24 +00:00
|
|
|
if( aLayer == LAYER_CONFLICTS_SHADOW )
|
2022-05-20 09:08:33 +00:00
|
|
|
{
|
2022-07-31 21:14:24 +00:00
|
|
|
const SHAPE_POLY_SET& frontpoly = aFootprint->GetCourtyard( F_CrtYd );
|
|
|
|
const SHAPE_POLY_SET& backpoly = aFootprint->GetCourtyard( B_CrtYd );
|
2022-05-20 09:08:33 +00:00
|
|
|
|
|
|
|
const COLOR4D color = m_pcbSettings.GetColor( aFootprint, aLayer );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
|
|
|
|
if( frontpoly.OutlineCount() > 0 )
|
|
|
|
m_gal->DrawPolygon( frontpoly );
|
|
|
|
|
|
|
|
if( backpoly.OutlineCount() > 0 )
|
|
|
|
m_gal->DrawPolygon( backpoly );
|
|
|
|
}
|
2014-07-09 13:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-12 11:23:30 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_GROUP* aGroup, int aLayer )
|
2020-08-11 19:37:07 +00:00
|
|
|
{
|
|
|
|
if( aLayer == LAYER_ANCHOR )
|
|
|
|
{
|
2020-12-29 12:33:37 +00:00
|
|
|
if( aGroup->IsSelected() && !( aGroup->GetParent() && aGroup->GetParent()->IsSelected() ) )
|
|
|
|
{
|
|
|
|
// Selected on our own; draw enclosing box
|
|
|
|
}
|
|
|
|
else if( aGroup->IsEntered() )
|
|
|
|
{
|
|
|
|
// Entered group; draw enclosing box
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-17 20:35:04 +00:00
|
|
|
// Neither selected nor entered; draw nothing at the group level (ie: only draw
|
|
|
|
// its members)
|
2020-12-23 21:42:55 +00:00
|
|
|
return;
|
2020-12-29 12:33:37 +00:00
|
|
|
}
|
2020-12-23 21:42:55 +00:00
|
|
|
|
2020-08-11 19:37:07 +00:00
|
|
|
const COLOR4D color = m_pcbSettings.GetColor( aGroup, LAYER_ANCHOR );
|
|
|
|
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth * 2.0f );
|
2022-08-31 09:15:42 +00:00
|
|
|
|
|
|
|
BOX2I bbox = aGroup->GetBoundingBox();
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I topLeft = bbox.GetPosition();
|
|
|
|
VECTOR2I width = VECTOR2I( bbox.GetWidth(), 0 );
|
|
|
|
VECTOR2I height = VECTOR2I( 0, bbox.GetHeight() );
|
2020-08-11 19:37:07 +00:00
|
|
|
|
2020-09-24 15:31:24 +00:00
|
|
|
m_gal->DrawLine( topLeft, topLeft + width );
|
|
|
|
m_gal->DrawLine( topLeft + width, topLeft + width + height );
|
|
|
|
m_gal->DrawLine( topLeft + width + height, topLeft + height );
|
|
|
|
m_gal->DrawLine( topLeft + height, topLeft );
|
2020-09-24 01:05:46 +00:00
|
|
|
|
|
|
|
wxString name = aGroup->GetName();
|
|
|
|
|
2021-09-17 20:35:04 +00:00
|
|
|
if( name.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2020-09-24 01:05:46 +00:00
|
|
|
int ptSize = 12;
|
|
|
|
int scaledSize = abs( KiROUND( m_gal->GetScreenWorldMatrix().GetScale().x * ptSize ) );
|
2022-09-16 23:42:20 +00:00
|
|
|
int unscaledSize = pcbIUScale.MilsToIU( ptSize );
|
2020-09-24 01:05:46 +00:00
|
|
|
|
|
|
|
// Scale by zoom a bit, but not too much
|
2022-01-11 13:47:21 +00:00
|
|
|
int textSize = ( scaledSize + ( unscaledSize * 2 ) ) / 3;
|
2022-01-11 00:49:49 +00:00
|
|
|
VECTOR2I textOffset = VECTOR2I( width.x / 2, -KiROUND( textSize * 0.5 ) );
|
|
|
|
VECTOR2I titleHeight = VECTOR2I( 0, KiROUND( textSize * 2.0 ) );
|
2020-09-24 01:05:46 +00:00
|
|
|
|
2021-09-04 21:08:52 +00:00
|
|
|
if( PrintableCharCount( name ) * textSize < bbox.GetWidth() )
|
2020-09-24 01:05:46 +00:00
|
|
|
{
|
2020-09-24 15:31:24 +00:00
|
|
|
m_gal->DrawLine( topLeft, topLeft - titleHeight );
|
|
|
|
m_gal->DrawLine( topLeft - titleHeight, topLeft + width - titleHeight );
|
|
|
|
m_gal->DrawLine( topLeft + width - titleHeight, topLeft + width );
|
|
|
|
|
2022-01-11 13:47:21 +00:00
|
|
|
TEXT_ATTRIBUTES attrs;
|
|
|
|
attrs.m_Italic = true;
|
|
|
|
attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER;
|
|
|
|
attrs.m_Valign = GR_TEXT_V_ALIGN_BOTTOM;
|
|
|
|
attrs.m_Size = VECTOR2I( textSize, textSize );
|
|
|
|
attrs.m_StrokeWidth = GetPenSizeForNormal( textSize );
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
KIFONT::FONT::GetFont()->Draw( m_gal, aGroup->GetName(), topLeft + textOffset, attrs,
|
|
|
|
aGroup->GetFontMetrics() );
|
2020-09-24 01:05:46 +00:00
|
|
|
}
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
void PCB_PAINTER::draw( const ZONE* aZone, int aLayer )
|
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
|
|
|
{
|
2022-10-07 21:21:24 +00:00
|
|
|
if( aLayer == LAYER_CONFLICTS_SHADOW )
|
|
|
|
{
|
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aZone, aLayer );
|
|
|
|
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
|
|
|
|
m_gal->DrawPolygon( aZone->Outline()->Outline( 0 ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-23 22:58:58 +00:00
|
|
|
/*
|
2020-07-11 17:42:00 +00:00
|
|
|
* aLayer will be the virtual zone layer (LAYER_ZONE_START, ... in GAL_LAYER_ID)
|
|
|
|
* This is used for draw ordering in the GAL.
|
|
|
|
* The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START )
|
|
|
|
* and the visibility comes from the combination of that copper layer and LAYER_ZONES
|
|
|
|
*/
|
2022-11-05 12:00:56 +00:00
|
|
|
PCB_LAYER_ID layer;
|
|
|
|
|
|
|
|
if( IsZoneFillLayer( aLayer ) )
|
|
|
|
layer = ToLAYER_ID( aLayer - LAYER_ZONE_START );
|
|
|
|
else
|
|
|
|
layer = ToLAYER_ID( aLayer );
|
2020-06-24 02:19:08 +00:00
|
|
|
|
|
|
|
if( !aZone->IsOnLayer( layer ) )
|
2017-10-23 13:35:03 +00:00
|
|
|
return;
|
|
|
|
|
2021-08-02 17:24:01 +00:00
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aZone, layer );
|
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
|
|
|
std::deque<VECTOR2D> corners;
|
2021-12-26 00:36:12 +00:00
|
|
|
ZONE_DISPLAY_MODE displayMode = m_pcbSettings.m_ZoneDisplayMode;
|
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-02 12:02:42 +00:00
|
|
|
// Draw the outline
|
2022-11-05 12:00:56 +00:00
|
|
|
if( !IsZoneFillLayer( aLayer ) )
|
2013-07-02 12:02:42 +00:00
|
|
|
{
|
2022-11-05 12:00:56 +00:00
|
|
|
const SHAPE_POLY_SET* outline = aZone->Outline();
|
2023-10-13 12:25:49 +00:00
|
|
|
bool allowDrawOutline = aZone->GetHatchStyle() != ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER;
|
2017-02-24 12:26:25 +00:00
|
|
|
|
2023-10-13 12:25:49 +00:00
|
|
|
if( allowDrawOutline && !m_pcbSettings.m_isPrinting && outline && outline->OutlineCount() > 0 )
|
2022-11-05 12:00:56 +00:00
|
|
|
{
|
|
|
|
m_gal->SetStrokeColor( color.a > 0.0 ? color.WithAlpha( 1.0 ) : color );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
2018-02-05 18:50:02 +00:00
|
|
|
|
2022-11-05 12:00:56 +00:00
|
|
|
// Draw each contour (main contour and holes)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* m_gal->DrawPolygon( *outline );
|
|
|
|
* should be enough, but currently does not work to draw holes contours in a complex
|
|
|
|
* polygon so each contour is draw as a simple polygon
|
|
|
|
*/
|
2018-02-05 18:50:02 +00:00
|
|
|
|
2022-11-09 00:03:59 +00:00
|
|
|
// Draw the main contour(s?)
|
|
|
|
for( int ii = 0; ii < outline->OutlineCount(); ++ii )
|
|
|
|
{
|
|
|
|
m_gal->DrawPolyline( outline->COutline( ii ) );
|
2018-02-05 18:50:02 +00:00
|
|
|
|
2022-11-09 00:03:59 +00:00
|
|
|
// Draw holes
|
|
|
|
int holes_count = outline->HoleCount( ii );
|
2018-02-05 18:50:02 +00:00
|
|
|
|
2022-11-09 04:30:07 +00:00
|
|
|
for( int jj = 0; jj < holes_count; ++jj )
|
2022-11-09 00:03:59 +00:00
|
|
|
m_gal->DrawPolyline( outline->CHole( ii, jj ) );
|
|
|
|
}
|
2018-02-05 18:50:02 +00:00
|
|
|
|
2022-11-05 12:00:56 +00:00
|
|
|
// Draw hatch lines
|
|
|
|
for( const SEG& hatchLine : aZone->GetHatchLines() )
|
|
|
|
m_gal->DrawLine( hatchLine.A, hatchLine.B );
|
|
|
|
}
|
2013-07-02 12:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the filling
|
2022-11-05 12:00:56 +00:00
|
|
|
if( IsZoneFillLayer( aLayer )
|
|
|
|
&& ( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED
|
|
|
|
|| displayMode == ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS
|
|
|
|
|| displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) )
|
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
|
|
|
{
|
2022-02-15 17:34:38 +00:00
|
|
|
const std::shared_ptr<SHAPE_POLY_SET>& polySet = aZone->GetFilledPolysList( layer );
|
2015-07-27 19:45:57 +00:00
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
if( polySet->OutlineCount() == 0 ) // Nothing to draw
|
2013-07-02 12:02:42 +00:00
|
|
|
return;
|
|
|
|
|
2019-03-07 20:09:03 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
2013-07-02 12:02:42 +00:00
|
|
|
m_gal->SetFillColor( color );
|
2022-02-11 12:42:09 +00:00
|
|
|
m_gal->SetLineWidth( 0 );
|
2013-07-02 12:02:42 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED )
|
2013-07-02 12:02:42 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( true );
|
2022-02-11 12:42:09 +00:00
|
|
|
m_gal->SetIsStroke( false );
|
2013-07-02 12:02:42 +00:00
|
|
|
}
|
2021-07-26 17:56:11 +00:00
|
|
|
else
|
2013-07-02 12:02:42 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
}
|
|
|
|
|
2023-10-22 08:55:18 +00:00
|
|
|
// On Opengl, a not convex filled polygon is usually drawn by using triangles
|
|
|
|
// as primitives. CacheTriangulation() can create basic triangle primitives to
|
|
|
|
// draw the polygon solid shape on Opengl. GLU tessellation is much slower,
|
|
|
|
// so currently we are using our tessellation.
|
|
|
|
if( m_gal->IsOpenGlEngine() && !polySet->IsTriangulationUpToDate() )
|
|
|
|
polySet->CacheTriangulation( true, true );
|
|
|
|
|
2022-02-15 17:34:38 +00:00
|
|
|
m_gal->DrawPolygon( *polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION );
|
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-03 09:19:13 +00:00
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
|
2013-04-03 09:19:13 +00:00
|
|
|
{
|
2022-05-06 17:13:10 +00:00
|
|
|
const COLOR4D& color = m_pcbSettings.GetColor( aDimension, aLayer );
|
2013-04-03 09:19:13 +00:00
|
|
|
|
2022-05-06 17:13:10 +00:00
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
2013-10-02 09:39:08 +00:00
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
2020-05-26 22:21:38 +00:00
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayGraphicsFill;
|
2021-12-26 00:36:12 +00:00
|
|
|
|
|
|
|
if( outline_mode )
|
2020-05-26 22:21:38 +00:00
|
|
|
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
|
|
|
|
else
|
2020-09-09 03:17:08 +00:00
|
|
|
m_gal->SetLineWidth( getLineThickness( aDimension->GetLineThickness() ) );
|
2013-10-02 09:39:08 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
// Draw dimension shapes
|
2020-09-12 20:09:40 +00:00
|
|
|
// TODO(JE) lift this out
|
|
|
|
for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
|
|
|
|
{
|
|
|
|
switch( shape->Type() )
|
|
|
|
{
|
|
|
|
case SH_SEGMENT:
|
|
|
|
{
|
|
|
|
const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
|
|
|
|
m_gal->DrawLine( seg.A, seg.B );
|
|
|
|
break;
|
|
|
|
}
|
2013-10-02 09:39:08 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
case SH_CIRCLE:
|
|
|
|
{
|
|
|
|
int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
|
|
|
|
m_gal->DrawCircle( shape->Centre(), radius );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-06-23 22:58:58 +00:00
|
|
|
|
2013-10-02 09:39:08 +00:00
|
|
|
// Draw text
|
2023-05-05 13:21:56 +00:00
|
|
|
wxString resolvedText = aDimension->GetShownText( true );
|
2023-03-04 23:15:43 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aDimension->GetAttributes();
|
2013-10-02 09:39:08 +00:00
|
|
|
|
2022-10-25 11:08:32 +00:00
|
|
|
if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::SideSpecificMask() ).any() )
|
2022-09-15 23:45:43 +00:00
|
|
|
attrs.m_Mirrored = !attrs.m_Mirrored;
|
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
if( outline_mode )
|
2021-12-31 14:07:24 +00:00
|
|
|
attrs.m_StrokeWidth = m_pcbSettings.m_outlineWidth;
|
2020-05-26 22:21:38 +00:00
|
|
|
else
|
2023-03-04 23:15:43 +00:00
|
|
|
attrs.m_StrokeWidth = getLineThickness( aDimension->GetEffectiveTextPenWidth() );
|
2020-05-26 22:21:38 +00:00
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
if( aDimension->GetFont() && aDimension->GetFont()->IsOutline() )
|
|
|
|
cache = aDimension->GetRenderCache( aDimension->GetFont(), resolvedText );
|
2022-01-04 23:00:00 +00:00
|
|
|
|
|
|
|
if( cache )
|
|
|
|
{
|
|
|
|
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
|
|
|
|
m_gal->DrawGlyph( *glyph.get() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-06 19:20:53 +00:00
|
|
|
strokeText( resolvedText, aDimension->GetTextPos(), attrs, aDimension->GetFontMetrics() );
|
2022-01-04 23:00:00 +00:00
|
|
|
}
|
2013-04-03 09:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
|
|
|
|
{
|
2014-05-21 21:13:30 +00:00
|
|
|
const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
|
2013-04-17 11:12:54 +00:00
|
|
|
VECTOR2D position( aTarget->GetPosition() );
|
|
|
|
double size, radius;
|
2013-04-03 09:19:13 +00:00
|
|
|
|
2017-02-07 10:21:26 +00:00
|
|
|
m_gal->SetLineWidth( getLineThickness( aTarget->GetWidth() ) );
|
2013-04-17 11:12:54 +00:00
|
|
|
m_gal->SetStrokeColor( strokeColor );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
|
|
|
|
m_gal->Save();
|
|
|
|
m_gal->Translate( position );
|
|
|
|
|
|
|
|
if( aTarget->GetShape() )
|
2013-04-03 09:19:13 +00:00
|
|
|
{
|
2013-04-17 11:12:54 +00:00
|
|
|
// shape x
|
|
|
|
m_gal->Rotate( M_PI / 4.0 );
|
|
|
|
size = 2.0 * aTarget->GetSize() / 3.0;
|
|
|
|
radius = aTarget->GetSize() / 2.0;
|
2013-04-03 09:19:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-17 11:12:54 +00:00
|
|
|
// shape +
|
|
|
|
size = aTarget->GetSize() / 2.0;
|
|
|
|
radius = aTarget->GetSize() / 3.0;
|
2013-04-03 09:19:13 +00:00
|
|
|
}
|
|
|
|
|
2013-09-16 14:18:43 +00:00
|
|
|
m_gal->DrawLine( VECTOR2D( -size, 0.0 ), VECTOR2D( size, 0.0 ) );
|
|
|
|
m_gal->DrawLine( VECTOR2D( 0.0, -size ), VECTOR2D( 0.0, size ) );
|
2013-04-17 11:12:54 +00:00
|
|
|
m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), radius );
|
|
|
|
|
|
|
|
m_gal->Restore();
|
2013-04-03 09:19:13 +00:00
|
|
|
}
|
2013-08-09 13:04:10 +00:00
|
|
|
|
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer )
|
2014-03-19 12:42:46 +00:00
|
|
|
{
|
2020-10-12 22:24:35 +00:00
|
|
|
bool isShadow = aLayer == LAYER_MARKER_SHADOWS;
|
|
|
|
|
2023-11-22 14:36:29 +00:00
|
|
|
// Don't paint invisible markers.
|
2020-10-12 22:24:35 +00:00
|
|
|
// It would be nice to do this through layer dependencies but we can't do an "or" there today
|
2023-11-22 14:36:29 +00:00
|
|
|
if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) )
|
2020-10-12 22:24:35 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-21 15:42:10 +00:00
|
|
|
const_cast<PCB_MARKER*>( aMarker )->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) );
|
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
SHAPE_LINE_CHAIN polygon;
|
|
|
|
aMarker->ShapeToPolygon( polygon );
|
2014-03-19 12:42:46 +00:00
|
|
|
|
2020-10-12 22:24:35 +00:00
|
|
|
COLOR4D color = m_pcbSettings.GetColor( aMarker, isShadow ? LAYER_MARKER_SHADOWS
|
|
|
|
: aMarker->GetColorLayer() );
|
2017-11-29 02:57:28 +00:00
|
|
|
|
2016-01-20 14:19:26 +00:00
|
|
|
m_gal->Save();
|
|
|
|
m_gal->Translate( aMarker->GetPosition() );
|
2020-10-12 22:24:35 +00:00
|
|
|
|
|
|
|
if( isShadow )
|
|
|
|
{
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetLineWidth( aMarker->MarkerScale() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
}
|
2020-11-18 01:21:04 +00:00
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
m_gal->DrawPolygon( polygon );
|
2016-01-20 14:19:26 +00:00
|
|
|
m_gal->Restore();
|
2014-03-19 12:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-16 11:33:56 +00:00
|
|
|
const double PCB_RENDER_SETTINGS::MAX_FONT_SIZE = pcbIUScale.mmToIU( 10.0 );
|