Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-02 22:57:13 +00:00
|
|
|
* Copyright (C) 2013-2017 CERN
|
2021-01-25 12:42:36 +00:00
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
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>
|
2016-05-09 15:23:01 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2021-03-22 19:34:33 +00:00
|
|
|
#include <trace_helpers.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
#include <view/view.h>
|
2013-08-20 13:07:38 +00:00
|
|
|
#include <view/view_group.h>
|
2016-12-02 17:58:12 +00:00
|
|
|
#include <view/view_item.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <view/view_rtree.h>
|
2018-08-23 21:54:42 +00:00
|
|
|
#include <view/view_overlay.h>
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <gal/definitions.h>
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2023-09-07 00:23:19 +00:00
|
|
|
#include <gal/painter.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
|
|
|
|
2023-09-07 11:22:10 +00:00
|
|
|
#include <core/profile.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-12-03 20:35:54 +00:00
|
|
|
#ifdef KICAD_GAL_PROFILE
|
|
|
|
#include <wx/log.h>
|
|
|
|
#endif
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
namespace KIGFX {
|
|
|
|
|
|
|
|
class VIEW;
|
|
|
|
|
|
|
|
class VIEW_ITEM_DATA
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VIEW_ITEM_DATA() :
|
2016-12-30 11:39:41 +00:00
|
|
|
m_view( nullptr ),
|
2016-12-02 17:58:12 +00:00
|
|
|
m_flags( KIGFX::VISIBLE ),
|
|
|
|
m_requiredUpdate( KIGFX::NONE ),
|
2017-04-01 12:48:13 +00:00
|
|
|
m_drawPriority( 0 ),
|
2016-12-02 17:58:12 +00:00
|
|
|
m_groups( nullptr ),
|
|
|
|
m_groupsSize( 0 ) {}
|
|
|
|
|
|
|
|
~VIEW_ITEM_DATA()
|
|
|
|
{
|
2017-01-16 13:23:22 +00:00
|
|
|
deleteGroups();
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
2021-10-03 12:58:56 +00:00
|
|
|
int GetFlags() const
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
return m_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class VIEW;
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return layer numbers used by the item.
|
2016-12-02 17:58:12 +00:00
|
|
|
*
|
|
|
|
* @param aLayers[]: output layer index array
|
|
|
|
* @param aCount: number of layer indices in aLayers[]
|
|
|
|
*/
|
|
|
|
void getLayers( int* aLayers, int& aCount ) const
|
|
|
|
{
|
|
|
|
int* layersPtr = aLayers;
|
|
|
|
|
2021-03-19 15:04:15 +00:00
|
|
|
for( int layer : m_layers )
|
2018-01-29 17:37:34 +00:00
|
|
|
*layersPtr++ = layer;
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2018-01-29 17:37:34 +00:00
|
|
|
aCount = m_layers.size();
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return number of the group id for the given layer, or -1 in case it was not cached before.
|
2016-12-02 17:58:12 +00:00
|
|
|
*
|
|
|
|
* @param aLayer is the layer number for which group id is queried.
|
|
|
|
* @return group id or -1 in case there is no group id (ie. item is not cached).
|
|
|
|
*/
|
2016-12-09 11:04:32 +00:00
|
|
|
int getGroup( int aLayer ) const
|
|
|
|
{
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
if( m_groups[i].first == aLayer )
|
|
|
|
return m_groups[i].second;
|
|
|
|
}
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Set a group id for the item and the layer combination.
|
2016-12-02 17:58:12 +00:00
|
|
|
*
|
2021-04-05 13:24:57 +00:00
|
|
|
* @param aLayer is the layer number.
|
2016-12-02 17:58:12 +00:00
|
|
|
* @param aGroup is the group id.
|
|
|
|
*/
|
|
|
|
void setGroup( int aLayer, int aGroup )
|
|
|
|
{
|
|
|
|
// Look if there is already an entry for the layer
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
if( m_groups[i].first == aLayer )
|
|
|
|
{
|
|
|
|
m_groups[i].second = aGroup;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there was no entry for the given layer - create one
|
2021-10-03 12:58:56 +00:00
|
|
|
std::pair<int, int>* newGroups = new std::pair<int, int>[m_groupsSize + 1];
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
if( m_groupsSize > 0 )
|
|
|
|
{
|
|
|
|
std::copy( m_groups, m_groups + m_groupsSize, newGroups );
|
|
|
|
delete[] m_groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_groups = newGroups;
|
2021-10-03 12:58:56 +00:00
|
|
|
newGroups[m_groupsSize++] = { aLayer, aGroup };
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Remove all of the stored group ids. Forces recaching of the item.
|
2016-12-02 17:58:12 +00:00
|
|
|
*/
|
|
|
|
void deleteGroups()
|
|
|
|
{
|
|
|
|
delete[] m_groups;
|
2017-01-16 13:23:22 +00:00
|
|
|
m_groups = nullptr;
|
2016-12-02 17:58:12 +00:00
|
|
|
m_groupsSize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return information if the item uses at least one group id (ie. if it is cached at all).
|
2016-12-02 17:58:12 +00:00
|
|
|
*
|
|
|
|
* @returns true in case it is cached at least for one layer.
|
|
|
|
*/
|
|
|
|
inline bool storesGroups() const
|
|
|
|
{
|
|
|
|
return m_groupsSize > 0;
|
|
|
|
}
|
|
|
|
|
2018-02-27 02:15:32 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Reorder the stored groups (to facilitate reordering of layers).
|
|
|
|
*
|
2018-02-27 02:15:32 +00:00
|
|
|
* @see VIEW::ReorderLayerData
|
|
|
|
*
|
|
|
|
* @param aReorderMap is the mapping of old to new layer ids
|
|
|
|
*/
|
|
|
|
void reorderGroups( std::unordered_map<int, int> aReorderMap )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
int orig_layer = m_groups[i].first;
|
|
|
|
int new_layer = orig_layer;
|
|
|
|
|
2022-07-25 15:15:02 +00:00
|
|
|
if( aReorderMap.count( orig_layer ) )
|
2018-02-27 02:15:32 +00:00
|
|
|
new_layer = aReorderMap.at( orig_layer );
|
|
|
|
|
|
|
|
m_groups[i].first = new_layer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Save layers used by the item.
|
2016-12-02 17:58:12 +00:00
|
|
|
*
|
|
|
|
* @param aLayers is an array containing layer numbers to be saved.
|
|
|
|
* @param aCount is the size of the array.
|
|
|
|
*/
|
|
|
|
void saveLayers( int* aLayers, int aCount )
|
|
|
|
{
|
2018-01-29 17:37:34 +00:00
|
|
|
m_layers.clear();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < aCount; ++i )
|
|
|
|
{
|
2023-12-24 01:21:58 +00:00
|
|
|
// this fires on some eagle board after PCB_IO_EAGLE::Load()
|
2016-12-02 17:58:12 +00:00
|
|
|
wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
|
|
|
|
|
2018-01-29 17:37:34 +00:00
|
|
|
m_layers.push_back( aLayers[i] );
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return current update flag for an item.
|
2016-12-02 17:58:12 +00:00
|
|
|
*/
|
|
|
|
int requiredUpdate() const
|
|
|
|
{
|
|
|
|
return m_requiredUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Mark an item as already updated, so it is not going to be redrawn.
|
2016-12-02 17:58:12 +00:00
|
|
|
*/
|
|
|
|
void clearUpdateFlags()
|
|
|
|
{
|
|
|
|
m_requiredUpdate = NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-25 12:42:36 +00:00
|
|
|
* Return if the item should be drawn or not.
|
2016-12-02 17:58:12 +00:00
|
|
|
*/
|
|
|
|
bool isRenderable() const
|
|
|
|
{
|
|
|
|
return m_flags == VISIBLE;
|
|
|
|
}
|
2021-06-08 17:47:06 +00:00
|
|
|
|
2021-10-03 12:58:56 +00:00
|
|
|
VIEW* m_view; ///< Current dynamic view the item is assigned to.
|
|
|
|
int m_flags; ///< Visibility flags
|
|
|
|
int m_requiredUpdate; ///< Flag required for updating
|
|
|
|
int m_drawPriority; ///< Order to draw this item in a layer, lowest first
|
2021-06-08 17:47:06 +00:00
|
|
|
|
2021-10-03 12:58:56 +00:00
|
|
|
std::pair<int, int>* m_groups; ///< layer_number:group_id pairs for each layer the
|
|
|
|
///< item occupies.
|
|
|
|
int m_groupsSize;
|
2021-06-08 17:47:06 +00:00
|
|
|
|
2021-10-03 12:58:56 +00:00
|
|
|
std::vector<int> m_layers; /// Stores layer numbers used by the item.
|
2016-12-02 17:58:12 +00:00
|
|
|
};
|
|
|
|
|
2016-12-12 10:50:09 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
void VIEW::OnDestroy( VIEW_ITEM* aItem )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
2023-04-16 13:21:05 +00:00
|
|
|
if( aItem->m_viewPrivData )
|
|
|
|
{
|
|
|
|
if( aItem->m_viewPrivData->m_view )
|
|
|
|
aItem->m_viewPrivData->m_view->VIEW::Remove( aItem );
|
2017-03-02 22:57:13 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
delete aItem->m_viewPrivData;
|
|
|
|
aItem->m_viewPrivData = nullptr;
|
|
|
|
}
|
2016-12-02 17:58:12 +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
|
|
|
|
2016-12-12 10:50:09 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
VIEW::VIEW( bool aIsDynamic ) :
|
2013-09-12 16:24:53 +00:00
|
|
|
m_enableOrderModifier( true ),
|
2015-05-18 11:48:13 +00:00
|
|
|
m_scale( 4.0 ),
|
2021-06-11 21:25:33 +00:00
|
|
|
m_minScale( 0.2 ), m_maxScale( 50000.0 ),
|
2016-12-12 10:51:08 +00:00
|
|
|
m_mirrorX( false ), m_mirrorY( false ),
|
2021-07-15 19:26:35 +00:00
|
|
|
m_painter( nullptr ),
|
|
|
|
m_gal( nullptr ),
|
2017-02-27 23:40:27 +00:00
|
|
|
m_dynamic( aIsDynamic ),
|
|
|
|
m_useDrawPriority( false ),
|
2017-09-17 22:36:18 +00:00
|
|
|
m_nextDrawPriority( 0 ),
|
|
|
|
m_reverseDrawOrder( false )
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
2018-11-18 19:04:17 +00:00
|
|
|
// Set m_boundary to define the max area size. The default area size
|
|
|
|
// is defined here as the max value of a int.
|
|
|
|
// this is a default value acceptable for Pcbnew and Gerbview, but too large for Eeschema.
|
|
|
|
// So in eeschema a call to SetBoundary() with a smaller value will be needed.
|
|
|
|
typedef std::numeric_limits<int> coord_limits;
|
|
|
|
double pos = coord_limits::lowest() / 2 + coord_limits::epsilon();
|
|
|
|
double size = coord_limits::max() - coord_limits::epsilon();
|
|
|
|
m_boundary.SetOrigin( pos, pos );
|
|
|
|
m_boundary.SetSize( size, size );
|
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems.reset( new std::vector<VIEW_ITEM*> );
|
|
|
|
m_allItems->reserve( 32768 );
|
2013-09-18 15:36:54 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
// Redraw everything at the beginning
|
2014-02-21 15:57:18 +00:00
|
|
|
MarkDirty();
|
2013-09-02 09:49:46 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
m_layers.reserve( VIEW_MAX_LAYERS );
|
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
// View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
|
|
|
|
// pad may be shown on pad, pad hole and solder paste layers). There are usual copper layers
|
|
|
|
// (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
|
|
|
|
// silkscreen, pads, vias, etc.
|
2020-08-10 21:52:22 +00:00
|
|
|
for( int ii = 0; ii < VIEW_MAX_LAYERS; ++ii )
|
|
|
|
{
|
|
|
|
m_layers.emplace_back();
|
|
|
|
m_layers[ii].items = std::make_shared<VIEW_RTREE>();
|
|
|
|
m_layers[ii].id = ii;
|
|
|
|
m_layers[ii].renderingOrder = ii;
|
|
|
|
m_layers[ii].visible = true;
|
|
|
|
m_layers[ii].displayOnly = false;
|
2021-08-24 16:00:46 +00:00
|
|
|
m_layers[ii].diffLayer = false;
|
|
|
|
m_layers[ii].hasNegatives = false;
|
2020-08-10 21:52:22 +00:00
|
|
|
m_layers[ii].target = TARGET_CACHED;
|
|
|
|
}
|
2018-07-05 06:35:50 +00:00
|
|
|
|
|
|
|
sortLayers();
|
2020-08-01 13:20:08 +00:00
|
|
|
|
|
|
|
m_preview.reset( new KIGFX::VIEW_GROUP() );
|
|
|
|
Add( m_preview.get() );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VIEW::~VIEW()
|
|
|
|
{
|
2020-08-01 13:20:08 +00:00
|
|
|
Remove( m_preview.get() );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
void VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
if( aDrawPriority < 0 )
|
|
|
|
aDrawPriority = m_nextDrawPriority++;
|
|
|
|
|
2017-03-02 22:57:13 +00:00
|
|
|
if( !aItem->m_viewPrivData )
|
|
|
|
aItem->m_viewPrivData = new VIEW_ITEM_DATA;
|
|
|
|
|
2023-04-17 16:52:28 +00:00
|
|
|
wxASSERT_MSG( aItem->m_viewPrivData->m_view == nullptr
|
|
|
|
|| aItem->m_viewPrivData->m_view == this,
|
|
|
|
wxS( "Already in a different view!" ) );
|
2023-04-16 13:21:05 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->m_viewPrivData->m_view = this;
|
2017-02-27 23:40:27 +00:00
|
|
|
aItem->m_viewPrivData->m_drawPriority = aDrawPriority;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
|
|
|
aItem->viewPrivData()->saveLayers( layers, layers_count );
|
2015-06-18 15:51:53 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems->push_back( aItem );
|
2016-12-07 09:20:31 +00:00
|
|
|
|
2014-02-24 11:56:47 +00:00
|
|
|
for( int i = 0; i < layers_count; ++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
|
|
|
{
|
2023-01-27 20:35:36 +00:00
|
|
|
wxCHECK2_MSG( layers[i] >= 0 && static_cast<unsigned>( layers[i] ) < m_layers.size(),
|
2023-04-16 13:21:05 +00:00
|
|
|
continue, wxS( "Invalid layer" ) );
|
2023-01-26 19:21:28 +00:00
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Insert( aItem );
|
2013-09-13 09:38:16 +00:00
|
|
|
MarkTargetDirty( l.target );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
SetVisible( aItem, true );
|
2017-09-25 01:22:23 +00:00
|
|
|
Update( aItem, KIGFX::INITIAL_ADD );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::Remove( VIEW_ITEM* aItem )
|
|
|
|
{
|
2023-04-16 13:21:05 +00:00
|
|
|
if( aItem && aItem->m_viewPrivData )
|
|
|
|
{
|
|
|
|
wxCHECK( aItem->m_viewPrivData->m_view == this, /*void*/ );
|
|
|
|
auto item = std::find( m_allItems->begin(), m_allItems->end(), aItem );
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
if( item != m_allItems->end() )
|
|
|
|
{
|
|
|
|
m_allItems->erase( item );
|
|
|
|
aItem->m_viewPrivData->clearUpdateFlags();
|
|
|
|
}
|
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-04-16 13:21:05 +00:00
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
aItem->m_viewPrivData->getLayers( layers, layers_count );
|
2014-03-10 15:01:15 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Remove( aItem );
|
|
|
|
MarkTargetDirty( l.target );
|
2014-03-10 15:01:15 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
// Clear the GAL cache
|
|
|
|
int prevGroup = aItem->m_viewPrivData->getGroup( layers[i] );
|
2013-09-02 09:49:46 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
if( prevGroup >= 0 )
|
|
|
|
m_gal->DeleteGroup( prevGroup );
|
|
|
|
}
|
2014-02-24 11:56:47 +00:00
|
|
|
|
2023-04-16 13:21:05 +00:00
|
|
|
aItem->m_viewPrivData->deleteGroups();
|
|
|
|
aItem->m_viewPrivData->m_view = nullptr;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-05 14:28:58 +00:00
|
|
|
void VIEW::SetRequired( int aLayerId, int aRequiredId, bool aRequired )
|
|
|
|
{
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayerId < m_layers.size(), /*void*/ );
|
|
|
|
wxCHECK( (unsigned) aRequiredId < m_layers.size(), /*void*/ );
|
2013-08-05 14:28:58 +00:00
|
|
|
|
|
|
|
if( aRequired )
|
|
|
|
m_layers[aLayerId].requiredLayers.insert( aRequiredId );
|
|
|
|
else
|
|
|
|
m_layers[aLayerId].requiredLayers.erase( aRequired );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-04 08:55:51 +00:00
|
|
|
// stupid C++... python lambda would do this in one line
|
2021-03-15 16:00:51 +00:00
|
|
|
template <class CONTAINER>
|
|
|
|
struct QUERY_VISITOR
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
typedef typename CONTAINER::value_type 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
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
QUERY_VISITOR( CONTAINER& aCont, 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
|
|
|
m_cont( aCont ), m_layer( aLayer )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
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-03 12:58:56 +00:00
|
|
|
if( aItem->viewPrivData()->GetFlags() & VISIBLE )
|
2013-10-14 18:40:36 +00:00
|
|
|
m_cont.push_back( VIEW::LAYER_ITEM_PAIR( aItem, m_layer ) );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
CONTAINER& m_cont;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
int m_layer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
int VIEW::Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const
|
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
|
|
|
{
|
|
|
|
if( m_orderedLayers.empty() )
|
|
|
|
return 0;
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
std::vector<VIEW_LAYER*>::const_reverse_iterator 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
|
|
|
|
|
|
|
// execute queries in reverse direction, so that items that are on the top of
|
|
|
|
// the rendering stack are returned first.
|
|
|
|
for( i = m_orderedLayers.rbegin(); i != m_orderedLayers.rend(); ++i )
|
|
|
|
{
|
|
|
|
// ignore layers that do not contain actual items (i.e. the selection box, menus, floats)
|
2018-10-05 04:22:20 +00:00
|
|
|
if( ( *i )->displayOnly || !( *i )->visible )
|
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
|
|
|
continue;
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
QUERY_VISITOR<std::vector<LAYER_ITEM_PAIR> > visitor( aResult, ( *i )->id );
|
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
|
|
|
( *i )->items->Query( aRect, visitor );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aResult.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const
|
|
|
|
{
|
2014-02-13 18:31:27 +00:00
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
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
|
|
|
|
|
|
|
if( aAbsolute )
|
|
|
|
return VECTOR2D( matrix * aCoord );
|
|
|
|
else
|
|
|
|
return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-27 15:13:27 +00:00
|
|
|
double VIEW::ToWorld( double aSize ) const
|
|
|
|
{
|
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
|
|
|
|
2017-11-16 00:05:11 +00:00
|
|
|
return fabs( matrix.GetScale().x * aSize );
|
2014-02-27 15:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
|
|
|
|
{
|
2014-02-13 18:31:27 +00:00
|
|
|
const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
|
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
|
|
|
|
|
|
|
if( aAbsolute )
|
|
|
|
return VECTOR2D( matrix * aCoord );
|
|
|
|
else
|
|
|
|
return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-01 01:22:50 +00:00
|
|
|
double VIEW::ToScreen( double aSize ) const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2015-07-01 01:22:50 +00:00
|
|
|
const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2015-07-01 01:22:50 +00:00
|
|
|
return matrix.GetScale().x * aSize;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::CopySettings( const VIEW* aOtherView )
|
|
|
|
{
|
2013-06-18 15:01:23 +00:00
|
|
|
wxASSERT_MSG( false, wxT( "This is not implemented" ) );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::SetGAL( GAL* aGal )
|
|
|
|
{
|
2018-09-28 08:10:08 +00:00
|
|
|
bool recacheGroups = ( m_gal != nullptr ); // recache groups only if GAL is reassigned
|
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
|
|
|
m_gal = aGal;
|
|
|
|
|
2013-05-10 14:05:40 +00:00
|
|
|
// clear group numbers, so everything is going to be recached
|
2018-09-28 08:10:08 +00:00
|
|
|
if( recacheGroups )
|
|
|
|
clearGroupCache();
|
2013-04-18 15:10:02 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
// every target has to be refreshed
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
2013-08-19 09:02:38 +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
|
|
|
// force the new GAL to display the current viewport.
|
|
|
|
SetCenter( m_center );
|
|
|
|
SetScale( m_scale );
|
2016-12-12 10:51:08 +00:00
|
|
|
SetMirror( m_mirrorX, m_mirrorY );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOX2D VIEW::GetViewport() const
|
|
|
|
{
|
|
|
|
BOX2D rect;
|
|
|
|
VECTOR2D screenSize = m_gal->GetScreenPixelSize();
|
|
|
|
|
|
|
|
rect.SetOrigin( ToWorld( VECTOR2D( 0, 0 ) ) );
|
|
|
|
rect.SetEnd( ToWorld( screenSize ) );
|
|
|
|
|
|
|
|
return rect.Normalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
void VIEW::SetViewport( const BOX2D& aViewport )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2015-07-01 01:22:50 +00:00
|
|
|
VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2023-09-03 12:30:32 +00:00
|
|
|
wxCHECK( fabs(ssize.x) > 0 && fabs(ssize.y) > 0, /*void*/ );
|
2014-07-09 09:22:43 +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
|
|
|
VECTOR2D centre = aViewport.Centre();
|
|
|
|
VECTOR2D vsize = aViewport.GetSize();
|
2014-07-09 09:22:42 +00:00
|
|
|
double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
|
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
|
|
|
|
|
|
|
SetCenter( centre );
|
|
|
|
SetScale( GetScale() * zoom );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::SetMirror( bool aMirrorX, bool aMirrorY )
|
|
|
|
{
|
2016-12-12 10:51:08 +00:00
|
|
|
wxASSERT_MSG( !aMirrorY, _( "Mirroring for Y axis is not supported yet" ) );
|
|
|
|
|
|
|
|
m_mirrorX = aMirrorX;
|
|
|
|
m_mirrorY = aMirrorY;
|
2013-08-27 16:08:32 +00:00
|
|
|
m_gal->SetFlip( aMirrorX, aMirrorY );
|
2016-12-12 10:50:46 +00:00
|
|
|
|
|
|
|
// Redraw everything
|
|
|
|
MarkDirty();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-08 09:06:53 +00:00
|
|
|
void VIEW::SetScale( double aScale, VECTOR2D aAnchor )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2019-08-08 09:06:53 +00:00
|
|
|
if( aAnchor == VECTOR2D( 0, 0 ) )
|
|
|
|
aAnchor = m_center;
|
|
|
|
|
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
|
|
|
VECTOR2D a = ToScreen( aAnchor );
|
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
if( aScale < m_minScale )
|
|
|
|
m_scale = m_minScale;
|
|
|
|
else if( aScale > m_maxScale )
|
|
|
|
m_scale = m_maxScale;
|
|
|
|
else
|
|
|
|
m_scale = aScale;
|
|
|
|
|
|
|
|
m_gal->SetZoomFactor( m_scale );
|
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
|
|
|
m_gal->ComputeWorldScreenMatrix();
|
|
|
|
|
|
|
|
VECTOR2D delta = ToWorld( a ) - aAnchor;
|
|
|
|
|
|
|
|
SetCenter( m_center - delta );
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
// Redraw everything after the viewport has changed
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::SetCenter( const VECTOR2D& aCenter )
|
|
|
|
{
|
|
|
|
m_center = aCenter;
|
2013-09-18 15:36:54 +00:00
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
if( !m_boundary.Contains( aCenter ) )
|
|
|
|
{
|
|
|
|
if( m_center.x < m_boundary.GetLeft() )
|
|
|
|
m_center.x = m_boundary.GetLeft();
|
|
|
|
else if( aCenter.x > m_boundary.GetRight() )
|
|
|
|
m_center.x = m_boundary.GetRight();
|
|
|
|
|
|
|
|
if( m_center.y < m_boundary.GetTop() )
|
|
|
|
m_center.y = m_boundary.GetTop();
|
|
|
|
else if( m_center.y > m_boundary.GetBottom() )
|
|
|
|
m_center.y = m_boundary.GetBottom();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
m_gal->SetLookAtPoint( m_center );
|
|
|
|
m_gal->ComputeWorldScreenMatrix();
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
// Redraw everything after the viewport has changed
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
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-03 12:27:15 +00:00
|
|
|
void VIEW::SetCenter( const VECTOR2D& aCenter, const std::vector<BOX2D>& obscuringScreenRects )
|
2018-01-30 06:45:53 +00:00
|
|
|
{
|
2021-10-03 12:27:15 +00:00
|
|
|
if( obscuringScreenRects.empty() )
|
|
|
|
return SetCenter( aCenter );
|
2018-01-30 06:45:53 +00:00
|
|
|
|
2021-10-03 12:27:15 +00:00
|
|
|
BOX2D screenRect( { 0, 0 }, m_gal->GetScreenPixelSize() );
|
|
|
|
SHAPE_POLY_SET unobscuredPoly( screenRect );
|
|
|
|
VECTOR2D unobscuredCenter = screenRect.Centre();
|
|
|
|
|
|
|
|
for( const BOX2D& obscuringScreenRect : obscuringScreenRects )
|
2018-01-30 06:45:53 +00:00
|
|
|
{
|
2021-10-03 12:27:15 +00:00
|
|
|
SHAPE_POLY_SET obscuringPoly( obscuringScreenRect );
|
|
|
|
unobscuredPoly.BooleanSubtract( obscuringPoly, SHAPE_POLY_SET::PM_FAST );
|
2018-01-30 06:45:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-03 12:27:15 +00:00
|
|
|
/*
|
|
|
|
* Perform a step-wise deflate to find the center of the largest unobscured area
|
|
|
|
*/
|
2018-01-30 06:45:53 +00:00
|
|
|
|
2021-10-03 12:27:15 +00:00
|
|
|
BOX2I bbox = unobscuredPoly.BBox();
|
|
|
|
int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
|
|
|
|
|
|
|
|
while( !unobscuredPoly.IsEmpty() )
|
2018-01-30 06:45:53 +00:00
|
|
|
{
|
2022-08-30 14:13:51 +00:00
|
|
|
unobscuredCenter = unobscuredPoly.BBox().Centre();
|
2023-10-05 07:34:24 +00:00
|
|
|
unobscuredPoly.Deflate( step, CORNER_STRATEGY::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
|
2018-01-30 06:45:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-03 12:27:15 +00:00
|
|
|
SetCenter( aCenter - ToWorld( unobscuredCenter - screenRect.Centre(), false ) );
|
2018-01-30 06:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-20 13:07:38 +00:00
|
|
|
m_layers[aLayer].renderingOrder = aRenderingOrder;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
sortLayers();
|
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
int VIEW::GetLayerOrder( int aLayer ) const
|
|
|
|
{
|
2013-10-14 14:13:35 +00:00
|
|
|
return m_layers.at( aLayer ).renderingOrder;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
void VIEW::SortLayers( int aLayers[], int& aCount ) const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-20 13:07:38 +00:00
|
|
|
int maxLay, maxOrd, maxIdx;
|
2013-06-26 14:31:52 +00:00
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
for( int i = 0; i < aCount; ++i )
|
|
|
|
{
|
|
|
|
maxLay = aLayers[i];
|
|
|
|
maxOrd = GetLayerOrder( maxLay );
|
|
|
|
maxIdx = i;
|
|
|
|
|
|
|
|
// Look for the max element in the range (j..aCount)
|
|
|
|
for( int j = i; j < aCount; ++j )
|
|
|
|
{
|
|
|
|
if( maxOrd < GetLayerOrder( aLayers[j] ) )
|
|
|
|
{
|
|
|
|
maxLay = aLayers[j];
|
|
|
|
maxOrd = GetLayerOrder( maxLay );
|
|
|
|
maxIdx = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Swap elements
|
|
|
|
aLayers[maxIdx] = aLayers[i];
|
|
|
|
aLayers[i] = maxLay;
|
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-27 02:15:32 +00:00
|
|
|
void VIEW::ReorderLayerData( std::unordered_map<int, int> aReorderMap )
|
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
std::vector<VIEW_LAYER> new_map;
|
|
|
|
new_map.reserve( m_layers.size() );
|
2018-02-27 02:15:32 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( const VIEW_LAYER& layer : m_layers )
|
2022-01-06 22:40:02 +00:00
|
|
|
new_map.push_back( layer );
|
2018-02-27 02:15:32 +00:00
|
|
|
|
2022-01-06 22:40:02 +00:00
|
|
|
for( auto& pair : aReorderMap )
|
|
|
|
{
|
|
|
|
new_map[pair.second] = m_layers[pair.first];
|
|
|
|
new_map[pair.second].id = pair.second;
|
2018-02-27 02:15:32 +00:00
|
|
|
}
|
|
|
|
|
2024-01-09 14:10:45 +00:00
|
|
|
// Transfer reordered data (using the copy assignment operator ):
|
|
|
|
m_layers = new_map;
|
2018-02-27 02:15:32 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-02-27 02:15:32 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = item->viewPrivData();
|
2018-02-27 02:15:32 +00:00
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
|
|
|
|
item->ViewGetLayers( layers, layers_count );
|
|
|
|
viewData->saveLayers( layers, layers_count );
|
|
|
|
|
|
|
|
viewData->reorderGroups( aReorderMap );
|
|
|
|
|
|
|
|
viewData->m_requiredUpdate |= COLOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
struct VIEW::UPDATE_COLOR_VISITOR
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
UPDATE_COLOR_VISITOR( int aLayer, PAINTER* aPainter, GAL* aGal ) :
|
|
|
|
layer( aLayer ),
|
|
|
|
painter( aPainter ),
|
|
|
|
gal( aGal )
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
|
|
|
// Obtain the color that should be used for coloring the item
|
2013-09-11 09:39:46 +00:00
|
|
|
const COLOR4D color = painter->GetSettings()->GetColor( aItem, layer );
|
2021-10-03 12:58:56 +00:00
|
|
|
int group = aItem->viewPrivData()->getGroup( layer );
|
2013-06-25 15:12:54 +00:00
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
if( group >= 0 )
|
2013-07-08 13:24:44 +00:00
|
|
|
gal->ChangeGroupColor( group, color );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int layer;
|
|
|
|
PAINTER* painter;
|
|
|
|
GAL* gal;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::UpdateLayerColor( int aLayer )
|
|
|
|
{
|
2013-07-08 13:24:44 +00:00
|
|
|
// There is no point in updating non-cached layers
|
2013-09-04 14:23:26 +00:00
|
|
|
if( !IsCached( aLayer ) )
|
2013-07-08 13:24:44 +00:00
|
|
|
return;
|
|
|
|
|
2013-06-25 15:12:54 +00:00
|
|
|
BOX2I r;
|
|
|
|
|
|
|
|
r.SetMaximum();
|
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
|
|
|
{
|
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
UPDATE_COLOR_VISITOR visitor( aLayer, m_painter, m_gal );
|
2018-10-26 21:25:09 +00:00
|
|
|
m_layers[aLayer].items->Query( r, visitor );
|
|
|
|
MarkTargetDirty( m_layers[aLayer].target );
|
|
|
|
}
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::UpdateAllLayersColor()
|
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
2013-06-25 15:12:54 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-10-26 21:25:09 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = item->viewPrivData();
|
2013-07-08 13:24:44 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( !viewData )
|
|
|
|
continue;
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
viewData->getLayers( layers, layers_count );
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
|
2021-10-03 12:58:56 +00:00
|
|
|
int group = viewData->getGroup( layers[i] );
|
2018-10-26 21:25:09 +00:00
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->ChangeGroupColor( group, color );
|
|
|
|
}
|
2018-02-25 20:38:05 +00:00
|
|
|
}
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
2013-09-12 16:24:53 +00:00
|
|
|
|
|
|
|
MarkDirty();
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
struct VIEW::UPDATE_DEPTH_VISITOR
|
2013-06-26 14:31:52 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
UPDATE_DEPTH_VISITOR( int aLayer, int aDepth, GAL* aGal ) :
|
|
|
|
layer( aLayer ),
|
|
|
|
depth( aDepth ),
|
|
|
|
gal( aGal )
|
2013-06-26 14:31:52 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
2013-06-26 14:31:52 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = aItem->viewPrivData()->getGroup( layer );
|
2013-06-26 14:31:52 +00:00
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
gal->ChangeGroupDepth( group, depth );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
2013-06-26 14:31:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int layer, depth;
|
|
|
|
GAL* gal;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
int VIEW::GetTopLayer() const
|
2013-09-18 11:14:57 +00:00
|
|
|
{
|
|
|
|
if( m_topLayers.size() == 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return *m_topLayers.begin();
|
|
|
|
}
|
|
|
|
|
2013-06-26 14:31:52 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
void VIEW::SetTopLayer( int aLayer, bool aEnabled )
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
if( aEnabled )
|
2013-06-26 14:31:52 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
if( m_topLayers.count( aLayer ) == 1 )
|
|
|
|
return;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
m_topLayers.insert( aLayer );
|
|
|
|
|
|
|
|
// Move the layer closer to front
|
|
|
|
if( m_enableOrderModifier )
|
|
|
|
m_layers[aLayer].renderingOrder += TOP_LAYER_MODIFIER;
|
|
|
|
}
|
|
|
|
else
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
if( m_topLayers.count( aLayer ) == 0 )
|
|
|
|
return;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
m_topLayers.erase( aLayer );
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
// Restore the previous rendering order
|
|
|
|
if( m_enableOrderModifier )
|
|
|
|
m_layers[aLayer].renderingOrder -= TOP_LAYER_MODIFIER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::EnableTopLayer( bool aEnable )
|
|
|
|
{
|
2013-10-14 14:13:35 +00:00
|
|
|
if( aEnable == m_enableOrderModifier )
|
|
|
|
return;
|
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
m_enableOrderModifier = aEnable;
|
|
|
|
|
|
|
|
std::set<unsigned int>::iterator it;
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
if( aEnable )
|
|
|
|
{
|
|
|
|
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
|
|
|
|
m_layers[*it].renderingOrder += TOP_LAYER_MODIFIER;
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
|
|
|
|
m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
2013-07-16 11:40:53 +00:00
|
|
|
|
|
|
|
UpdateAllLayersOrder();
|
|
|
|
UpdateAllLayersColor();
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
void VIEW::ClearTopLayers()
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
std::set<unsigned int>::iterator it;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
if( m_enableOrderModifier )
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
// Restore the previous rendering order for layers that were marked as top
|
|
|
|
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
|
|
|
|
m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
2013-07-16 07:26:29 +00:00
|
|
|
|
|
|
|
m_topLayers.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::UpdateAllLayersOrder()
|
|
|
|
{
|
2013-06-26 14:31:52 +00:00
|
|
|
sortLayers();
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
2013-07-16 07:26:29 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-10-26 21:25:09 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = item->viewPrivData();
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( !viewData )
|
|
|
|
continue;
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
viewData->getLayers( layers, layers_count );
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
int group = viewData->getGroup( layers[i] );
|
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
|
|
|
|
}
|
2018-02-25 20:38:05 +00:00
|
|
|
}
|
2013-07-16 07:26:29 +00:00
|
|
|
}
|
2013-09-12 16:24:53 +00:00
|
|
|
|
|
|
|
MarkDirty();
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
struct VIEW::DRAW_ITEM_VISITOR
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
DRAW_ITEM_VISITOR( VIEW* aView, int aLayer, bool aUseDrawPriority, bool aReverseDrawOrder ) :
|
|
|
|
view( aView ),
|
|
|
|
layer( aLayer ),
|
2017-09-17 22:36:18 +00:00
|
|
|
useDrawPriority( aUseDrawPriority ),
|
2023-03-11 12:42:58 +00:00
|
|
|
reverseDrawOrder( aReverseDrawOrder ),
|
2023-03-12 12:56:12 +00:00
|
|
|
drawForcedTransparent( false ),
|
|
|
|
foundForcedTransparent( false )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( aItem->viewPrivData(), false );
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2023-03-11 12:42:58 +00:00
|
|
|
if( aItem->m_forcedTransparency > 0 && !drawForcedTransparent )
|
|
|
|
{
|
|
|
|
foundForcedTransparent = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-09-25 01:22:23 +00:00
|
|
|
// Conditions that have to be fulfilled for an item to be drawn
|
2021-10-03 12:58:56 +00:00
|
|
|
bool drawCondition = aItem->viewPrivData()->isRenderable()
|
|
|
|
&& aItem->ViewGetLOD( layer, view ) < view->m_scale;
|
2013-07-08 07:28:58 +00:00
|
|
|
if( !drawCondition )
|
2013-11-13 16:03:22 +00:00
|
|
|
return true;
|
2013-07-08 07:28:58 +00:00
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
if( useDrawPriority )
|
|
|
|
drawItems.push_back( aItem );
|
|
|
|
else
|
|
|
|
view->draw( aItem, layer );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return 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
|
|
|
}
|
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
void deferredDraw()
|
|
|
|
{
|
2017-09-17 22:36:18 +00:00
|
|
|
if( reverseDrawOrder )
|
2021-10-03 12:58:56 +00:00
|
|
|
{
|
2017-09-17 22:36:18 +00:00
|
|
|
std::sort( drawItems.begin(), drawItems.end(),
|
2021-08-18 21:16:17 +00:00
|
|
|
[]( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool
|
|
|
|
{
|
|
|
|
return b->viewPrivData()->m_drawPriority < a->viewPrivData()->m_drawPriority;
|
|
|
|
} );
|
2021-10-03 12:58:56 +00:00
|
|
|
}
|
2017-09-17 22:36:18 +00:00
|
|
|
else
|
2021-10-03 12:58:56 +00:00
|
|
|
{
|
2017-09-17 22:36:18 +00:00
|
|
|
std::sort( drawItems.begin(), drawItems.end(),
|
2021-08-18 21:16:17 +00:00
|
|
|
[]( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool
|
|
|
|
{
|
|
|
|
return a->viewPrivData()->m_drawPriority < b->viewPrivData()->m_drawPriority;
|
|
|
|
} );
|
2021-10-03 12:58:56 +00:00
|
|
|
}
|
2017-02-27 23:40:27 +00:00
|
|
|
|
2021-03-19 15:04:15 +00:00
|
|
|
for( VIEW_ITEM* item : drawItems )
|
2017-02-27 23:40:27 +00:00
|
|
|
view->draw( item, layer );
|
|
|
|
}
|
|
|
|
|
2013-07-04 15:02:20 +00:00
|
|
|
VIEW* view;
|
2014-07-09 09:22:42 +00:00
|
|
|
int layer, layers[VIEW_MAX_LAYERS];
|
2017-09-17 22:36:18 +00:00
|
|
|
bool useDrawPriority, reverseDrawOrder;
|
2017-02-27 23:40:27 +00:00
|
|
|
std::vector<VIEW_ITEM*> drawItems;
|
2023-03-11 12:42:58 +00:00
|
|
|
bool drawForcedTransparent;
|
|
|
|
bool foundForcedTransparent;
|
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-04 09:18:47 +00:00
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
void VIEW::redrawRect( const BOX2I& aRect )
|
|
|
|
{
|
2016-06-29 20:07:55 +00:00
|
|
|
for( VIEW_LAYER* l : m_orderedLayers )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2014-02-21 15:57:18 +00:00
|
|
|
if( l->visible && IsTargetDirty( l->target ) && areRequiredLayersEnabled( l->id ) )
|
2013-04-02 09:02:35 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
DRAW_ITEM_VISITOR drawFunc( this, l->id, m_useDrawPriority, m_reverseDrawOrder );
|
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-23 16:39:07 +00:00
|
|
|
m_gal->SetTarget( l->target );
|
2013-07-16 07:26:29 +00:00
|
|
|
m_gal->SetLayerDepth( l->renderingOrder );
|
2021-08-24 16:00:46 +00:00
|
|
|
|
|
|
|
// Differential layer also work for the negatives, since both special layer types
|
|
|
|
// will composite on separate layers (at least in Cairo)
|
|
|
|
if( l->diffLayer )
|
|
|
|
m_gal->StartDiffLayer();
|
|
|
|
else if( l->hasNegatives )
|
|
|
|
m_gal->StartNegativesLayer();
|
|
|
|
|
2013-04-02 09:02:35 +00:00
|
|
|
l->items->Query( aRect, drawFunc );
|
2017-02-27 23:40:27 +00:00
|
|
|
|
|
|
|
if( m_useDrawPriority )
|
|
|
|
drawFunc.deferredDraw();
|
2021-08-24 16:00:46 +00:00
|
|
|
|
|
|
|
if( l->diffLayer )
|
|
|
|
m_gal->EndDiffLayer();
|
|
|
|
else if( l->hasNegatives )
|
|
|
|
m_gal->EndNegativesLayer();
|
2023-03-11 12:42:58 +00:00
|
|
|
|
|
|
|
if( drawFunc.foundForcedTransparent )
|
|
|
|
{
|
|
|
|
drawFunc.drawForcedTransparent = true;
|
|
|
|
|
|
|
|
m_gal->SetTarget( TARGET_NONCACHED );
|
|
|
|
m_gal->EnableDepthTest( true );
|
|
|
|
m_gal->SetLayerDepth( l->renderingOrder );
|
|
|
|
|
|
|
|
l->items->Query( aRect, drawFunc );
|
|
|
|
}
|
2013-04-02 09:02:35 +00:00
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 08:52:50 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
if( IsCached( aLayer ) && !aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
|
|
|
// Draw using cached information or create one
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( aLayer );
|
2013-08-20 13:07:38 +00:00
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->DrawGroup( group );
|
|
|
|
else
|
2017-09-28 07:57:46 +00:00
|
|
|
Update( aItem );
|
2013-08-20 13:07:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Immediate mode
|
|
|
|
if( !m_painter->Draw( aItem, aLayer ) )
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
2013-08-20 13:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
2013-09-02 09:49:46 +00:00
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
// Sorting is needed for drawing order dependent GALs (like Cairo)
|
2013-08-20 13:07:38 +00:00
|
|
|
SortLayers( layers, layers_count );
|
|
|
|
|
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
2013-11-06 17:17:42 +00:00
|
|
|
m_gal->SetLayerDepth( m_layers.at( layers[i] ).renderingOrder );
|
2013-08-20 13:07:38 +00:00
|
|
|
draw( aItem, layers[i], aImmediate );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-16 13:23:22 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
2016-12-09 11:04:32 +00:00
|
|
|
for( unsigned int i = 0; i < aGroup->GetSize(); i++)
|
2016-11-04 21:29:47 +00:00
|
|
|
draw( aGroup->GetItem(i), aImmediate );
|
2013-08-02 14:51:38 +00:00
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
struct VIEW::RECACHE_ITEM_VISITOR
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
RECACHE_ITEM_VISITOR( VIEW* aView, GAL* aGal, int aLayer ) :
|
|
|
|
view( aView ),
|
|
|
|
gal( aGal ),
|
|
|
|
layer( aLayer )
|
2013-04-30 15:55:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-09 14:48:34 +00:00
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
return false;
|
|
|
|
|
2013-05-10 14:05:40 +00:00
|
|
|
// Remove previously cached group
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( layer );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( group >= 0 )
|
|
|
|
gal->DeleteGroup( group );
|
2013-04-30 15:55:24 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->setGroup( layer, -1 );
|
|
|
|
view->Update( aItem );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
2013-04-18 15:10:02 +00:00
|
|
|
}
|
2013-04-30 15:55:24 +00:00
|
|
|
|
|
|
|
VIEW* view;
|
|
|
|
GAL* gal;
|
|
|
|
int layer;
|
2013-04-18 15:10: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
|
|
|
void VIEW::Clear()
|
|
|
|
{
|
|
|
|
BOX2I r;
|
|
|
|
r.SetMaximum();
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems->clear();
|
2015-06-04 12:54:07 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
layer.items->RemoveAll();
|
2013-06-18 14:20:29 +00:00
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
m_nextDrawPriority = 0;
|
|
|
|
|
2013-07-04 15:02:20 +00:00
|
|
|
m_gal->ClearCache();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-13 09:28:47 +00:00
|
|
|
void VIEW::ClearTargets()
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-26 08:43:22 +00:00
|
|
|
if( IsTargetDirty( TARGET_CACHED ) || IsTargetDirty( TARGET_NONCACHED ) )
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
|
|
|
// TARGET_CACHED and TARGET_NONCACHED have to be redrawn together, as they contain
|
|
|
|
// layers that rely on each other (eg. netnames are noncached, but tracks - are cached)
|
|
|
|
m_gal->ClearTarget( TARGET_NONCACHED );
|
|
|
|
m_gal->ClearTarget( TARGET_CACHED );
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
2013-08-26 08:43:22 +00:00
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
if( IsTargetDirty( TARGET_OVERLAY ) )
|
|
|
|
{
|
|
|
|
m_gal->ClearTarget( TARGET_OVERLAY );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
2013-08-26 08:43:22 +00:00
|
|
|
}
|
2013-08-20 13:07:38 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
|
|
|
|
void VIEW::Redraw()
|
|
|
|
{
|
2021-04-30 23:24:09 +00:00
|
|
|
#ifdef KICAD_GAL_PROFILE
|
2022-09-17 18:43:46 +00:00
|
|
|
PROF_TIMER totalRealTime;
|
2021-04-30 23:24:09 +00:00
|
|
|
#endif /* KICAD_GAL_PROFILE */
|
2014-03-11 09:58:58 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
VECTOR2D screenSize = m_gal->GetScreenPixelSize();
|
2019-01-04 00:51:05 +00:00
|
|
|
BOX2D rect( ToWorld( VECTOR2D( 0, 0 ) ),
|
2013-08-26 08:43:22 +00:00
|
|
|
ToWorld( screenSize ) - ToWorld( VECTOR2D( 0, 0 ) ) );
|
2019-01-04 00:51:05 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
rect.Normalize();
|
2019-01-04 00:51:05 +00:00
|
|
|
BOX2I recti( rect.GetPosition(), rect.GetSize() );
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2021-10-03 12:58:56 +00:00
|
|
|
// The view rtree uses integer positions. Large screens can overflow this size so in
|
|
|
|
// this case, simply set the rectangle to the full rtree.
|
|
|
|
if( rect.GetWidth() > std::numeric_limits<int>::max()
|
|
|
|
|| rect.GetHeight() > std::numeric_limits<int>::max() )
|
|
|
|
{
|
2019-01-04 00:51:05 +00:00
|
|
|
recti.SetMaximum();
|
2021-10-03 12:58:56 +00:00
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2019-01-04 00:51:05 +00:00
|
|
|
redrawRect( recti );
|
2021-08-24 16:00:46 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
// All targets were redrawn, so nothing is dirty
|
2021-08-24 16:00:46 +00:00
|
|
|
MarkClean();
|
2014-03-11 09:58:58 +00:00
|
|
|
|
2021-04-30 23:24:09 +00:00
|
|
|
#ifdef KICAD_GAL_PROFILE
|
2016-12-31 12:00:24 +00:00
|
|
|
totalRealTime.Stop();
|
2023-01-17 04:14:38 +00:00
|
|
|
wxLogTrace( traceGalProfile, wxS( "VIEW::Redraw(): %.1f ms" ), totalRealTime.msecs() );
|
2021-04-30 23:24:09 +00:00
|
|
|
#endif /* KICAD_GAL_PROFILE */
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-20 07:47:31 +00:00
|
|
|
const VECTOR2I& VIEW::GetScreenPixelSize() const
|
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 m_gal->GetScreenPixelSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-15 16:00:51 +00:00
|
|
|
struct VIEW::CLEAR_LAYER_CACHE_VISITOR
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
CLEAR_LAYER_CACHE_VISITOR( VIEW* aView ) :
|
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
|
|
|
view( aView )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->viewPrivData()->deleteGroups();
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
|
|
VIEW* view;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::clearGroupCache()
|
|
|
|
{
|
|
|
|
BOX2I r;
|
|
|
|
|
|
|
|
r.SetMaximum();
|
2021-03-15 16:00:51 +00:00
|
|
|
CLEAR_LAYER_CACHE_VISITOR visitor( this );
|
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-08-10 21:52:22 +00:00
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
layer.items->Query( r, visitor );
|
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-18 15:10:02 +00:00
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2017-09-25 01:22:23 +00:00
|
|
|
if( aUpdateFlags & INITIAL_ADD )
|
2017-07-24 14:18:09 +00:00
|
|
|
{
|
2017-09-25 01:22:23 +00:00
|
|
|
// Don't update layers or bbox, since it was done in VIEW::Add()
|
|
|
|
// Now that we have initialized, set flags to ALL for the code below
|
|
|
|
aUpdateFlags = ALL;
|
2017-07-24 14:18:09 +00:00
|
|
|
}
|
2017-09-25 01:22:23 +00:00
|
|
|
else
|
2017-07-24 14:18:09 +00:00
|
|
|
{
|
2021-01-25 12:42:36 +00:00
|
|
|
// updateLayers updates geometry too, so we do not have to update both of them at the
|
|
|
|
// same time
|
2017-09-25 01:22:23 +00:00
|
|
|
if( aUpdateFlags & LAYERS )
|
|
|
|
updateLayers( aItem );
|
|
|
|
else if( aUpdateFlags & GEOMETRY )
|
|
|
|
updateBbox( aItem );
|
2017-07-24 14:18:09 +00:00
|
|
|
}
|
2013-09-04 14:23:26 +00:00
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
// Iterate through layers used by the item and recache it immediately
|
2014-02-21 15:57:18 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2013-09-02 09:49:46 +00:00
|
|
|
int layerId = layers[i];
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( IsCached( layerId ) )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2018-02-25 20:01:17 +00:00
|
|
|
if( aUpdateFlags & ( GEOMETRY | LAYERS | REPAINT ) )
|
2013-09-04 14:23:26 +00:00
|
|
|
updateItemGeometry( aItem, layerId );
|
2016-12-02 17:58:12 +00:00
|
|
|
else if( aUpdateFlags & COLOR )
|
2014-02-21 15:57:18 +00:00
|
|
|
updateItemColor( aItem, layerId );
|
2013-08-07 15:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mark those layers as dirty, so the VIEW will be refreshed
|
2013-09-13 09:38:16 +00:00
|
|
|
MarkTargetDirty( m_layers[layerId].target );
|
2013-08-07 15:20:01 +00:00
|
|
|
}
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->viewPrivData()->clearUpdateFlags();
|
2013-08-07 15:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
void VIEW::sortLayers()
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
m_orderedLayers.resize( m_layers.size() );
|
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
m_orderedLayers[n++] = &layer;
|
2013-08-20 13:07:38 +00:00
|
|
|
|
|
|
|
sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder );
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
2013-08-20 13:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
|
|
|
|
wxCHECK( IsCached( aLayer ), /*void*/ );
|
2013-08-07 15:20:01 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
// Obtain the color that should be used for coloring the item on the specific layerId
|
2013-09-11 09:39:46 +00:00
|
|
|
const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( aLayer );
|
2013-08-07 15:20:01 +00:00
|
|
|
|
|
|
|
// Change the color, only if it has group assigned
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->ChangeGroupColor( group, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
|
|
|
|
wxCHECK( IsCached( aLayer ), /*void*/ );
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
VIEW_LAYER& l = m_layers.at( aLayer );
|
|
|
|
|
|
|
|
m_gal->SetTarget( l.target );
|
|
|
|
m_gal->SetLayerDepth( l.renderingOrder );
|
|
|
|
|
|
|
|
// Redraw the item from scratch
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( aLayer );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->DeleteGroup( group );
|
2013-10-02 11:57:21 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
group = m_gal->BeginGroup();
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->setGroup( aLayer, group );
|
|
|
|
|
2023-09-25 23:30:33 +00:00
|
|
|
if( !m_painter->Draw( aItem, aLayer ) )
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
2014-02-24 13:31:55 +00:00
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
m_gal->EndGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
void VIEW::updateBbox( VIEW_ITEM* aItem )
|
|
|
|
{
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
|
|
|
|
2014-02-24 13:31:55 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2013-09-04 14:23:26 +00:00
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Remove( aItem );
|
|
|
|
l.items->Insert( aItem );
|
2013-09-13 09:38:16 +00:00
|
|
|
MarkTargetDirty( l.target );
|
2013-09-04 14:23:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
void VIEW::updateLayers( VIEW_ITEM* aItem )
|
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
2013-09-24 13:48:04 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
// Remove the item from previous layer set
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->getLayers( layers, layers_count );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2014-02-24 13:31:55 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2013-09-24 13:48:04 +00:00
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Remove( aItem );
|
|
|
|
MarkTargetDirty( l.target );
|
2013-12-09 09:42:38 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( IsCached( l.id ) )
|
|
|
|
{
|
|
|
|
// Redraw the item from scratch
|
2016-12-02 17:58:12 +00:00
|
|
|
int prevGroup = viewData->getGroup( layers[i] );
|
2013-12-09 09:42:38 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( prevGroup >= 0 )
|
|
|
|
{
|
|
|
|
m_gal->DeleteGroup( prevGroup );
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->setGroup( l.id, -1 );
|
2014-02-21 15:57:18 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-24 13:48:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add the item to new layer set
|
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->saveLayers( layers, layers_count );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
for( int i = 0; i < layers_count; i++ )
|
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Insert( aItem );
|
|
|
|
MarkTargetDirty( l.target );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-05 14:28:58 +00:00
|
|
|
bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
|
2013-07-08 07:28:58 +00:00
|
|
|
{
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayerId < m_layers.size(), false );
|
2013-08-05 14:28:58 +00:00
|
|
|
|
2016-01-17 17:31:00 +00:00
|
|
|
std::set<int>::const_iterator it, it_end;
|
2013-08-05 14:28:58 +00:00
|
|
|
|
2021-10-03 12:58:56 +00:00
|
|
|
for( int layer : m_layers.at( aLayerId ).requiredLayers )
|
2013-07-08 07:28:58 +00:00
|
|
|
{
|
2013-08-05 14:28:58 +00:00
|
|
|
// That is enough if just one layer is not enabled
|
2021-10-03 12:58:56 +00:00
|
|
|
if( !m_layers.at( layer ).visible || !areRequiredLayersEnabled( layer ) )
|
2013-07-08 07:28:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
void VIEW::RecacheAllItems()
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
|
|
|
BOX2I r;
|
|
|
|
|
|
|
|
r.SetMaximum();
|
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( const VIEW_LAYER& l : m_layers )
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
if( IsCached( l.id ) )
|
2013-07-04 15:02:20 +00:00
|
|
|
{
|
2021-03-15 16:00:51 +00:00
|
|
|
RECACHE_ITEM_VISITOR visitor( this, m_gal, l.id );
|
2020-08-10 21:52:22 +00:00
|
|
|
l.items->Query( r, visitor );
|
2013-07-04 15:02:20 +00:00
|
|
|
}
|
2013-05-10 14:05:40 +00:00
|
|
|
}
|
2013-04-18 15:10:02 +00:00
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::UpdateItems()
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
2023-04-12 02:09:05 +00:00
|
|
|
if( !m_gal->IsVisible() || !m_gal->IsInitialized() )
|
2021-11-21 16:33:13 +00:00
|
|
|
return;
|
|
|
|
|
2021-11-28 22:06:40 +00:00
|
|
|
unsigned int cntGeomUpdate = 0;
|
2022-11-18 23:02:05 +00:00
|
|
|
bool anyUpdated = false;
|
2021-11-21 16:33:13 +00:00
|
|
|
|
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2014-02-21 15:57:18 +00:00
|
|
|
{
|
2021-11-28 22:06:40 +00:00
|
|
|
auto vpd = item->viewPrivData();
|
|
|
|
|
|
|
|
if( !vpd )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( vpd->m_requiredUpdate != NONE )
|
|
|
|
{
|
2022-11-18 23:02:05 +00:00
|
|
|
anyUpdated = true;
|
|
|
|
|
|
|
|
if( vpd->m_requiredUpdate & ( GEOMETRY | LAYERS ) )
|
|
|
|
{
|
|
|
|
cntGeomUpdate++;
|
|
|
|
}
|
2021-11-21 16:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2021-11-28 22:06:40 +00:00
|
|
|
unsigned int cntTotal = m_allItems->size();
|
|
|
|
|
|
|
|
double ratio = (double) cntGeomUpdate / (double) cntTotal;
|
2021-11-21 16:33:13 +00:00
|
|
|
|
|
|
|
// Optimization to improve view update time. If a lot of items (say, 30%) have their
|
|
|
|
// bboxes/geometry changed it's way faster (around 10 times) to rebuild the R-Trees
|
|
|
|
// from scratch rather than update the bbox of each changed item. Pcbnew does multiple
|
|
|
|
// full geometry updates during file load, this can save a solid 30 seconds on load time
|
|
|
|
// for larger designs...
|
|
|
|
|
|
|
|
if( ratio > 0.3 )
|
|
|
|
{
|
|
|
|
auto allItems = *m_allItems;
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
|
|
|
|
|
|
|
// kill all Rtrees
|
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
layer.items->RemoveAll();
|
|
|
|
|
|
|
|
// and re-insert items from scratch
|
|
|
|
for( VIEW_ITEM* item : allItems )
|
2017-01-16 13:23:22 +00:00
|
|
|
{
|
2021-11-21 16:33:13 +00:00
|
|
|
item->ViewGetLayers( layers, layers_count );
|
|
|
|
item->viewPrivData()->saveLayers( layers, layers_count );
|
|
|
|
|
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2018-10-26 21:25:09 +00:00
|
|
|
{
|
2023-01-27 20:35:36 +00:00
|
|
|
wxCHECK2_MSG( layers[i] >= 0 && static_cast<unsigned>( layers[i] ) < m_layers.size(),
|
|
|
|
continue, wxS( "Invalid layer" ) );
|
2021-11-21 16:33:13 +00:00
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Insert( item );
|
|
|
|
MarkTargetDirty( l.target );
|
2018-10-26 21:25:09 +00:00
|
|
|
}
|
2021-11-21 16:33:13 +00:00
|
|
|
|
|
|
|
item->viewPrivData()->m_requiredUpdate &= ~( LAYERS | GEOMETRY );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 23:02:05 +00:00
|
|
|
if( anyUpdated )
|
2021-11-21 16:33:13 +00:00
|
|
|
{
|
2021-11-28 22:06:40 +00:00
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
|
|
|
|
|
|
|
for( VIEW_ITEM* item : *m_allItems.get() )
|
2021-11-21 16:33:13 +00:00
|
|
|
{
|
2021-11-28 22:06:40 +00:00
|
|
|
if( item->viewPrivData() && item->viewPrivData()->m_requiredUpdate != NONE )
|
|
|
|
{
|
|
|
|
invalidateItem( item, item->viewPrivData()->m_requiredUpdate );
|
|
|
|
item->viewPrivData()->m_requiredUpdate = NONE;
|
|
|
|
}
|
2017-01-16 13:23:22 +00:00
|
|
|
}
|
2014-02-21 15:57:18 +00:00
|
|
|
}
|
2021-11-28 22:06:40 +00:00
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
KI_TRACE( traceGalProfile, wxS( "View update: total items %u, geom %u anyUpdated %u\n" ), cntTotal,
|
2022-11-18 23:10:38 +00:00
|
|
|
cntGeomUpdate, (unsigned) anyUpdated );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
2014-05-14 11:48:29 +00:00
|
|
|
|
|
|
|
|
2018-02-25 17:38:35 +00:00
|
|
|
void VIEW::UpdateAllItems( int aUpdateFlags )
|
|
|
|
{
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-02-25 17:38:35 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
if( item->viewPrivData() )
|
|
|
|
item->viewPrivData()->m_requiredUpdate |= aUpdateFlags;
|
2018-02-25 17:38:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-25 20:14:28 +00:00
|
|
|
void VIEW::UpdateAllItemsConditionally( int aUpdateFlags,
|
|
|
|
std::function<bool( VIEW_ITEM* )> aCondition )
|
|
|
|
{
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-02-25 20:14:28 +00:00
|
|
|
{
|
|
|
|
if( aCondition( item ) )
|
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
if( item->viewPrivData() )
|
|
|
|
item->viewPrivData()->m_requiredUpdate |= aUpdateFlags;
|
2018-02-25 20:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-03 13:25:20 +00:00
|
|
|
void VIEW::UpdateAllItemsConditionally( std::function<int( VIEW_ITEM* )> aItemFlagsProvider )
|
|
|
|
{
|
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
|
|
|
{
|
|
|
|
if( item->viewPrivData() )
|
|
|
|
item->viewPrivData()->m_requiredUpdate |= aItemFlagsProvider( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
std::unique_ptr<VIEW> VIEW::DataReference() const
|
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
std::unique_ptr<VIEW> ret = std::make_unique<VIEW>();
|
2018-07-05 06:35:50 +00:00
|
|
|
ret->m_allItems = m_allItems;
|
|
|
|
ret->m_layers = m_layers;
|
|
|
|
ret->sortLayers();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
void VIEW::SetVisible( VIEW_ITEM* aItem, bool aIsVisible )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
bool cur_visible = viewData->m_flags & VISIBLE;
|
|
|
|
|
|
|
|
if( cur_visible != aIsVisible )
|
|
|
|
{
|
|
|
|
if( aIsVisible )
|
|
|
|
viewData->m_flags |= VISIBLE;
|
|
|
|
else
|
|
|
|
viewData->m_flags &= ~VISIBLE;
|
|
|
|
|
|
|
|
Update( aItem, APPEARANCE | COLOR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2023-10-14 17:22:17 +00:00
|
|
|
void VIEW::Hide( VIEW_ITEM* aItem, bool aHide, bool aHideOverlay )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
if( !( viewData->m_flags & VISIBLE ) )
|
|
|
|
return;
|
|
|
|
|
2023-10-14 17:22:17 +00:00
|
|
|
if( aHideOverlay )
|
2023-10-14 11:11:46 +00:00
|
|
|
viewData->m_flags |= OVERLAY_HIDDEN;
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
if( aHide )
|
|
|
|
viewData->m_flags |= HIDDEN;
|
|
|
|
else
|
2023-10-14 11:11:46 +00:00
|
|
|
viewData->m_flags &= ~( HIDDEN | OVERLAY_HIDDEN );
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
Update( aItem, APPEARANCE );
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
|
|
|
bool VIEW::IsVisible( const VIEW_ITEM* aItem ) const
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
2021-03-19 15:04:15 +00:00
|
|
|
const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2019-10-15 13:39:54 +00:00
|
|
|
return viewData && ( viewData->m_flags & VISIBLE );
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2023-10-14 11:11:46 +00:00
|
|
|
bool VIEW::IsHiddenOnOverlay( const VIEW_ITEM* aItem ) const
|
|
|
|
{
|
|
|
|
const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
|
|
|
|
|
|
|
return viewData && ( viewData->m_flags & OVERLAY_HIDDEN );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-12 16:58:30 +00:00
|
|
|
bool VIEW::HasItem( const VIEW_ITEM* aItem ) const
|
|
|
|
{
|
|
|
|
const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
|
|
|
|
|
|
|
return viewData && viewData->m_view == this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-27 11:03:35 +00:00
|
|
|
void VIEW::Update( const VIEW_ITEM* aItem ) const
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
Update( aItem, ALL );
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2020-10-27 11:03:35 +00:00
|
|
|
void VIEW::Update( const VIEW_ITEM* aItem, int aUpdateFlags ) const
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
2020-08-01 13:20:08 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
if( !viewData )
|
2016-12-02 17:58:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
assert( aUpdateFlags != NONE );
|
2016-12-05 22:54:41 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->m_requiredUpdate |= aUpdateFlags;
|
|
|
|
}
|
|
|
|
|
2018-08-23 21:54:42 +00:00
|
|
|
|
|
|
|
std::shared_ptr<VIEW_OVERLAY> VIEW::MakeOverlay()
|
|
|
|
{
|
2022-02-06 02:26:36 +00:00
|
|
|
std::shared_ptr<VIEW_OVERLAY> overlay = std::make_shared<VIEW_OVERLAY>();
|
2018-08-23 21:54:42 +00:00
|
|
|
|
|
|
|
Add( overlay.get() );
|
|
|
|
return overlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-01 13:20:08 +00:00
|
|
|
void VIEW::ClearPreview()
|
|
|
|
{
|
2021-02-16 18:08:31 +00:00
|
|
|
if( !m_preview )
|
|
|
|
return;
|
2020-08-01 13:20:08 +00:00
|
|
|
|
2021-02-16 18:08:31 +00:00
|
|
|
m_preview->Clear();
|
2020-08-01 13:20:08 +00:00
|
|
|
|
2023-09-25 23:30:33 +00:00
|
|
|
for( VIEW_ITEM* item : m_ownedItems )
|
2021-02-16 18:08:31 +00:00
|
|
|
delete item;
|
|
|
|
|
|
|
|
m_ownedItems.clear();
|
|
|
|
Update( m_preview.get() );
|
2020-08-01 13:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-15 20:13:08 +00:00
|
|
|
void VIEW::InitPreview()
|
|
|
|
{
|
|
|
|
m_preview.reset( new KIGFX::VIEW_GROUP() );
|
|
|
|
Add( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-09-25 23:30:33 +00:00
|
|
|
void VIEW::AddToPreview( VIEW_ITEM* aItem, bool aTakeOwnership )
|
2020-08-01 13:20:08 +00:00
|
|
|
{
|
|
|
|
Hide( aItem, false );
|
|
|
|
m_preview->Add( aItem );
|
|
|
|
|
|
|
|
if( aTakeOwnership )
|
|
|
|
m_ownedItems.push_back( aItem );
|
|
|
|
|
|
|
|
SetVisible( m_preview.get(), true );
|
|
|
|
Hide( m_preview.get(), false );
|
|
|
|
Update( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::ShowPreview( bool aShow )
|
|
|
|
{
|
|
|
|
SetVisible( m_preview.get(), aShow );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-11 07:51:00 +00:00
|
|
|
} // namespace KIGFX
|